-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install includes to include/${PROJECT_NAME} and export library target #28
Conversation
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
CI (supplemental repos build: |
@sloretz This fix has caused the header file to be installed in include/angles/angles/angles.h and causes packages including angles/angles.h to fail with file not found since it is installed in the wrong place |
|
||
ament_export_include_directories(include) | ||
install(DIRECTORY include/ DESTINATION include/angles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be
install(DIRECTORY include/ DESTINATION include)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sloretz This fix has caused the header file to be installed in include/angles/angles/angles.h and causes packages including angles/angles.h to fail with file not found since it is installed in the wrong place
This change is intentional, see ros2/ros2#1150 for why. This PR also removed the old-style CMake variable angles_INCLUDE_DIR
. If a package isn't building, that's probably why. The correct fix is to link against the exported interface target
# If your target includes angles headers in it's public headers use this:
target_link_libraries(mylibrary PUBLIC angles::angles)
# If your target only includes angles headers in source files or non-installed headers, use this:
target_link_libraries(mylibrary PRIVATE angles::angles)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thank you
@sloretz I actually think we need to do some additional work here. In particular, the |
FILES_MATCHING PATTERN "*.h") | ||
add_library(angles INTERFACE) | ||
target_link_libraries(angles INTERFACE | ||
"$<INSTALL_INTERFACE:install/angles>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, this is broken! It should be target_include_directories
This installs includes to
include/${PROJECT_NAME}
to mitigate include directory search order issues when overriding packages indesktop
.It also replaces the old-style CMake variable export with a modern CMake target export. Dependencies using
ament_target_dependencies(MyTarget angles)
will still work, but now they can use modern CMake targets instead.Part of ros2/ros2#1150
Part of ament/ament_cmake#365