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 use modern CMake #493

Merged
merged 12 commits into from
Apr 1, 2022

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Jan 5, 2022

Part of ros2/ros2#1150

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

Part of ament/ament_cmake#365

This removes ament_export_libraries and ament_export_include_directories as they're redundant with the exported CMake targets in packages that I was already changing. I only updated packages that installed headers.

Part of ament/ament_cmake#292

This replaces ament_target_dependencies() calls with target_link_libraries() in packages that I was already changing. I only updated packages that installed headers.

This also removes the dependency on eigen3_cmake_module in packages that I was already changing. It's no longer necessary now that we can use modern CMake targets. I only updated packages that installed headers.

Requires ros2/rclcpp#1855 for the rclcpp_components::component target.

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

I've left a number of questions inline. I basically have two overarching questions:

  1. If we remove ament_export_include_directories and ament_export_libraries, what happens to downstream projects that are depending on the old-style CMake variables?
  2. I'm fine with switching from ament_target_dependencies to target_link_libraries where we can, but shouldn't we be explicitly listing all dependencies in target_link_libraries? There seem to be a number of places where we are now implicitly depending on other targets.

@sloretz
Copy link
Contributor Author

sloretz commented Jan 10, 2022

If we remove ament_export_include_directories and ament_export_libraries, what happens to downstream projects that are depending on the old-style CMake variables?

So far, they all still work. The reason is all the downstream projects I've come across are using ament_target_dependencies(), which reads either old-style CMake variables or CMake targets.

A common CMake pattern I've seen outside of ROS is to put exported targets into a "..._LIBRARIES" variable taking advantage of downstream targets are likely already doing target_link_libraries(...) with it. However, ament_cmake puts the targets into a separate ..._TARGETS variable, so that doesn't apply here.

I'm fine with switching from ament_target_dependencies to target_link_libraries where we can, but shouldn't we be explicitly listing all dependencies in target_link_libraries? There seem to be a number of places where we are now implicitly depending on other targets.

I've been intentionally leaving it off when a target is getting dependencies from another target in the same CMake project. My reasoning is it tests that the CMake target we're exporting properly made those targets as PUBLIC or INTERFACE. Say there was a package with a shared library and a test executable. Now say there's a bug where the shared library says it depends on rclcpp::rclcpp with the PRIVATE keyword, but it should have used the PUBLIC keyword. If the test also target_link_libraries(... rclcpp::rclcpp) then the project will build fine and the tests will pass, but when that package is released downstream projects will fail to build because the shared library target didn't properly export it's dependency on rclcpp::rclcpp. If the test instead got that dependency from the shared library target then the test would have failed to build and caught that bug before release.

sloretz added 2 commits March 31, 2022 11:45

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz sloretz force-pushed the sloretz__easy_idso_part1 branch from 0703d79 to 89fa9bc Compare March 31, 2022 18:45
sloretz added 7 commits March 31, 2022 11:47
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz sloretz requested a review from clalancette March 31, 2022 23:53
@sloretz
Copy link
Contributor Author

sloretz commented Mar 31, 2022

I rebased this and addressed all feedback.

CI

  • build: --packages-above-and-dependencies examples_tf2_py geometry2 test_tf2 tf2 tf2_bullet tf2_eigen tf2_eigen_kdl tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_ros_py tf2_sensor_msgs tf2_tools
  • test: --packages-select examples_tf2_py geometry2 test_tf2 tf2 tf2_bullet tf2_eigen tf2_eigen_kdl tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_ros_py tf2_sensor_msgs tf2_tools

Jobs

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

@sloretz
Copy link
Contributor Author

sloretz commented Apr 1, 2022

https://github.com/ros2/choco-packages/blob/latest/package/eigen/share/cmake/Eigen3Config.cmake

Windows CI failed because we ship a custom Eigen3Config.cmake on Windows that doesn't provide targets instead of using upstreams. This is the same reason I upgraded bullet, but I don't have time to upgrade that one before the freeze. I'll undo all the target stuff for packages using Eigen to get Windows to pass.

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz
Copy link
Contributor Author

sloretz commented Apr 1, 2022

5cedb80 should resolve the windows issue. CI rerun:

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

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

I've left a couple of minor things (and Windows CI needs to be fixed). With those things done, I'll be happy to approve.

sloretz added 2 commits April 1, 2022 08:58
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz
Copy link
Contributor Author

sloretz commented Apr 1, 2022

CI re-run:

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

@sloretz
Copy link
Contributor Author

sloretz commented Apr 1, 2022

CI LGTM 🎉 @clalancette Mind taking another look?

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.

2 participants