Skip to content

Remove ament_target_dependencies to match ROS 2 Rolling#32

Merged
sgillen merged 3 commits into
NVIDIA-ISAAC-ROS:mainfrom
bmchalenv:add-missing-ament-cmake
Feb 26, 2026
Merged

Remove ament_target_dependencies to match ROS 2 Rolling#32
sgillen merged 3 commits into
NVIDIA-ISAAC-ROS:mainfrom
bmchalenv:add-missing-ament-cmake

Conversation

@bmchalenv
Copy link
Copy Markdown
Contributor

@bmchalenv bmchalenv commented Feb 26, 2026

Apparently ROS 2 on rolling is fully deprecating ament_target_dependencies 😮 #572

Update the Cmakelist to do the same. Recently in Jan 2026 it was fully removed. The post I linked is the reasons for doing it.

Signed-off-by: Blake McHale <bmchale@nvidia.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 26, 2026

Greptile Summary

This PR changes the CMake linking approach from ROS 2's ament_target_dependencies() to standard CMake target_link_libraries() using ${package_TARGETS} variables. It also removes the explicit find_package(ament_cmake REQUIRED) line that was added in commit 0c10299.

Key changes:

  • Replaced all ament_target_dependencies() calls with target_link_libraries() using ${package_TARGETS} variables (e.g., ${rclcpp_TARGETS}, ${std_msgs_TARGETS})
  • Removed explicit find_package(ament_cmake REQUIRED) statement
  • Applied the pattern consistently across all executables and test targets

Concerns:

  • PR title is misleading: Title says "Add ament_cmake as package" but the PR actually removes the explicit find_package(ament_cmake REQUIRED) line
  • Deviates from ROS 2 conventions: Standard ROS 2 practice is to use ament_target_dependencies() which properly handles dependencies across different ROS 2 versions
  • Reliance on ${package_TARGETS} variables: Assumes all dependencies export these CMake variables, which may not be universally true
  • The commit message "Test new target link libraries" suggests this is experimental

Confidence Score: 3/5

  • This PR may work but introduces unconventional CMake patterns that deviate from ROS 2 best practices
  • Score reflects concerns about deviating from standard ROS 2 build patterns. While the code may compile and run, using target_link_libraries() with ${package_TARGETS} instead of ament_target_dependencies() is non-standard and could cause issues with packages that don't export TARGETS variables. The misleading PR title and removal of explicit ament_cmake dependency also raise questions about the approach.
  • greenwave_monitor/CMakeLists.txt requires attention - verify that the build succeeds and all package dependencies properly export ${package_TARGETS} variables

Important Files Changed

Filename Overview
greenwave_monitor/CMakeLists.txt Replaced ament_target_dependencies() with target_link_libraries() using ${package_TARGETS} variables; removed explicit find_package(ament_cmake REQUIRED) line

Last reviewed commit: 834eb64

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Signed-off-by: Blake McHale <bmchale@nvidia.com>
Comment thread greenwave_monitor/CMakeLists.txt Outdated
Signed-off-by: Blake McHale <bmchale@nvidia.com>
Comment on lines +33 to 39
target_link_libraries(greenwave_monitor
greenwave_diagnostics
${rclcpp_TARGETS}
${std_msgs_TARGETS}
${diagnostic_msgs_TARGETS}
${greenwave_monitor_interfaces_TARGETS}
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changed from ament_target_dependencies() to target_link_libraries() with ${package_TARGETS} variables. This deviates from standard ROS 2 practice. ament_target_dependencies() is the recommended approach as it properly handles include directories, link libraries, and compile definitions across different ROS 2 versions.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ament_target_dependencies is deprecated, so we need to switch.

Comment thread greenwave_monitor/CMakeLists.txt
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 26, 2026

Additional Comments (1)

greenwave_monitor/CMakeLists.txt
The explicit find_package(ament_cmake REQUIRED) added in commit 0c10299 was removed. While ament_cmake_auto provides ament_cmake transitively, explicit dependencies are clearer, especially since ament_package() (line 195) comes from ament_cmake.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@bmchalenv bmchalenv changed the title Add ament_cmake as package in CMakelist Remove ament_target_dependencies to match ROS 2 Rolling Feb 26, 2026
@sgillen sgillen merged commit 40a7010 into NVIDIA-ISAAC-ROS:main Feb 26, 2026
17 checks passed
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