Skip to content

Use target_link_libraries instead of ament_target_dependencies#1202

Merged
MichaelOrlov merged 5 commits intoros2:rollingfrom
wep21:feature/modern-cmake
Feb 23, 2023
Merged

Use target_link_libraries instead of ament_target_dependencies#1202
MichaelOrlov merged 5 commits intoros2:rollingfrom
wep21:feature/modern-cmake

Conversation

@wep21
Copy link
Contributor

@wep21 wep21 commented Dec 10, 2022

Use target_link_libraries instead of ament_target_dependencies for modern cmake.

See discussion on ament/ament_cmake#292 for context on this decision.

This method will be the new standard recommendation after merge of ros2/ros2_documentation#2915

@wep21 wep21 requested a review from a team as a code owner December 10, 2022 19:07
@wep21 wep21 requested review from emersonknapp and gbiggs and removed request for a team December 10, 2022 19:07
@wep21 wep21 force-pushed the feature/modern-cmake branch 2 times, most recently from 06f9538 to 06e959b Compare December 11, 2022 06:05
@emersonknapp
Copy link
Collaborator

Can you explain why you are making this change? Is there a new recommendation from ament_cmake that you use target_link_libraries? This is not more "modern" - target_link_libraries already existed when ament_cmake was first written, ament_target_dependencies does more than just library linking.

Without a strong justification and context for this change, I am not inclined to move forward.

@wep21
Copy link
Contributor Author

wep21 commented Dec 12, 2022

@emersonknapp Please see this issue.

@emersonknapp
Copy link
Collaborator

ament/ament_cmake#292 is not closed, and I'm not seeing a documentation update changing recommendations for downstream packages. Unless I am missing it and there has been such a documentation update?
Please add this context to the PR description, we need to know "why?" in addition to "what?"

@clalancette
Copy link
Contributor

Unless I am missing it and there has been such a documentation update?

There is a documentation update in the works: ros2/ros2_documentation#2915 .

We still use ament_target_dependencies in many places in the core code, and in many more places in the wider ecosystem. It isn't going anywhere anytime soon, but its core functionality mostly does overlap with target_link_libraries. So we are (slowly) changing over the core to just use target_link_libraries where we can, which is likely where this came from.

@emersonknapp
Copy link
Collaborator

Thanks for the link to the docs. I have updated the PR description with all the context. Just skeptical of changes without an obvious reason - I'm fine moving forward with this, maybe delaying to "depends on ros2/ros2_documentation#2915"

@emersonknapp
Copy link
Collaborator

Just from a nitpicky smell and flavor perspective, I'll note that I don't love that now you have to repeat yourself with package::package naming. But, you know, whatever. Not every nutritious thing tastes good.

yaml_cpp_vendor
target_link_libraries(writer_benchmark
rclcpp::rclcpp
${std_msgs_TARGETS}
Copy link
Collaborator

@emersonknapp emersonknapp Dec 12, 2022

Choose a reason for hiding this comment

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

Actually - this makes me very suspicious of this change! As an end user, how am I supposed to know when I need ${pkg_TARGETS} vs pkg::pkg vs {pkg_LIBRARIES}? This seems strictly worse!

Copy link
Contributor

Choose a reason for hiding this comment

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

So this is a bug in the current CMake code that is generated for message packages (and is one of the main reasons this has been a "soft" changeover so far).

That is, we really, really want this to be std_msgs::std_msgs, but we have so far been unable to make that work properly (and we have tried). For now, the workaround has been to stick with x_msgs_TARGETS for all msgs packages, and use modern CMake targets for everything else.

Whether you want to reject this PR because of that, I'll leave to you. I'll point out that we are accepting this elsewhere in the core for now.

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

It seems migration out of ament_target_dependencies unavoidable since it will become deprecated soon.
I also don't like a workaround with ${test_msgs_TARGETS} and another messages files, but I am tend to incline to make incremental fixes rather than waiting when it will be solved thoroughly.
Overall movements towards standard cmake target_link_libraries looks reasonable, however I am bit concerned that relevant PR ros2/ros2_documentation#2915 for official documentation update is sort of in stale stage and hasn't been moved forward or updated for a 4 months.

@wep21 wep21 force-pushed the feature/modern-cmake branch from a8bd934 to 7c8e43a Compare December 15, 2022 16:08
@wep21 wep21 force-pushed the feature/modern-cmake branch from 7c8e43a to 2f98d6e Compare December 15, 2022 16:13
@wep21 wep21 requested a review from MichaelOrlov December 17, 2022 15:49
Daisuke Nishimatsu added 4 commits February 16, 2023 23:58
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
@wep21 wep21 force-pushed the feature/modern-cmake branch from c736a97 to b031acf Compare February 16, 2023 15:18
@wep21
Copy link
Contributor Author

wep21 commented Feb 16, 2023

@emersonknapp @MichaelOrlov @clalancette I rebased the branch from latest rolling. Please review again.

Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

OK - it seems fine with green CI

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@wep21 Please consider to address one nitpick.
And I have a couple questions about missing target dependencies. Please see them in dedicated comments.

Co-authored-by: Michael Orlov <morlovmr@gmail.com>
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
@wep21 wep21 force-pushed the feature/modern-cmake branch from 41ce10e to f18b6c7 Compare February 22, 2023 04:19
@wep21 wep21 requested a review from MichaelOrlov February 22, 2023 04:24
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@wep21 Thanks for the PR.
LGTM now.

@MichaelOrlov
Copy link
Contributor

Gist: https://gist.githubusercontent.com/MichaelOrlov/759beca6bdc37394a5b4cbaa6b22736b/raw/d3221f0176000106c912c1f23ab407c4a7830804/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_compression rosbag2_compression_zstd rosbag2_transport rosbag2_cpp rosbag2_examples_cpp rosbag2_performance_benchmarking rosbag2_py rosbag2_storage rosbag2_storage_mcap rosbag2_storage_sqlite3 rosbag2_test_common rosbag2_test
TEST args: --packages-above rosbag2_compression rosbag2_compression_zstd rosbag2_transport rosbag2_cpp rosbag2_examples_cpp rosbag2_performance_benchmarking rosbag2_py rosbag2_storage rosbag2_storage_mcap rosbag2_storage_sqlite3 rosbag2_test_common rosbag2_test
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/11478

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

@MichaelOrlov MichaelOrlov changed the title refactor: use target link libraries instead of ament target dependencies Use target link libraries instead of ament target dependencies Feb 22, 2023
@MichaelOrlov MichaelOrlov changed the title Use target link libraries instead of ament target dependencies Use target_link_libraries instead of ament_target_dependencies Feb 22, 2023
@MichaelOrlov
Copy link
Contributor

Gist: https://gist.githubusercontent.com/MichaelOrlov/8ef3c7b32ac9aac982f412fdc29bae53/raw/d3221f0176000106c912c1f23ab407c4a7830804/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_compression rosbag2_compression_zstd rosbag2_transport rosbag2_cpp rosbag2_examples_cpp rosbag2_performance_benchmarking rosbag2_py rosbag2_storage rosbag2_storage_mcap rosbag2_storage_sqlite3 rosbag2_test_common rosbag2_tests
TEST args: --packages-above rosbag2_compression rosbag2_compression_zstd rosbag2_transport rosbag2_cpp rosbag2_examples_cpp rosbag2_performance_benchmarking rosbag2_py rosbag2_storage rosbag2_storage_mcap rosbag2_storage_sqlite3 rosbag2_test_common rosbag2_tests
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/11480

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

@MichaelOrlov MichaelOrlov merged commit 260e20e into ros2:rolling Feb 23, 2023
@wep21 wep21 deleted the feature/modern-cmake branch February 23, 2023 13:34
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.

4 participants