Skip to content
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

Merged
merged 1 commit into from
Jan 14, 2022

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Jan 5, 2022

This installs includes to include/${PROJECT_NAME} to mitigate include directory search order issues when overriding packages in desktop.

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.

target_link_libraries(MyTarget PRIVATE angles::angles)

Part of ros2/ros2#1150
Part of ament/ament_cmake#365

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz sloretz self-assigned this Jan 5, 2022
@sloretz sloretz marked this pull request as ready for review January 10, 2022 23:42
@sloretz
Copy link
Contributor Author

sloretz commented Jan 14, 2022

CI (supplemental repos build: --packages-up-to angles test: --packages-select angles)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@sloretz sloretz merged commit 1c07a74 into ros2 Jan 14, 2022
@sloretz sloretz deleted the sloretz__easy_idso_part1 branch January 14, 2022 22:26
@asobhy-qnx
Copy link

asobhy-qnx commented Jan 15, 2022

@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)

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)

Copy link
Contributor Author

@sloretz sloretz Jan 16, 2022

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thank you

@clalancette
Copy link

@sloretz I actually think we need to do some additional work here. In particular, the ros2 branch as used here is used for all of Foxy, Galactic, and Rolling. This change is one we want on Rolling, but I don't think it should be released into Foxy or Galactic. So I'll suggest that we branch off Foxy and Galactic before this commit.

FILES_MATCHING PATTERN "*.h")
add_library(angles INTERFACE)
target_link_libraries(angles INTERFACE
"$<INSTALL_INTERFACE:install/angles>")
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants