Skip to content

Conversation

@aminya
Copy link
Owner

@aminya aminya commented Oct 18, 2022

Imported targets that include prebuilt libraries cannot be installed using package_project now. This tries to fix the issue

How to test

Try to import an externally built library and re-export it

add_library(built_by_bazel SHARED IMPORTED)
set_property(TARGET built_by_bazel PROPERTY IMPORTED_LOCATION "./bazel-bin/libbuilt_by_bazel.so")
set_target_properties(built_by_bazel PROPERTIES LINKER_LANGUAGE CXX)

target_link_libraries(built_by_bazel INTERFACE project_options project_warnings) # link project_options/warnings

set(INCLUDE_DIR "include") # must be relative paths
target_include_directories(
  built_by_bazel INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_DIR}>"
                             "$<INSTALL_INTERFACE:./${CMAKE_INSTALL_INCLUDEDIR}>"
)

# Package the project
package_project(
  TARGETS
  built_by_bazel
  PUBLIC_INCLUDES
  ${INCLUDE_DIR}
)

TODO

When the _filtered_list_targets is empty, nothing will be exported, which results in an error. In this case, the imported targets should be exported too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants