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

Deprecate ament_target_dependencies() #572

Draft
wants to merge 2 commits into
base: rolling
Choose a base branch
from

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Mar 15, 2025

Draft until these two prerequisite PRs are merged:

Requires #571
Requires ros2/system_tests#566


This PR deprecates ament_target_dependencies() in favor of target_link_libraries(). This PR also adds a deprecation warning that suggests a target_link_libraries() call to be used instead.

For example, I inserted a call to ament_target_dependencies into my local copy of tf2_ros:

ament_target_dependencies(${PROJECT_NAME} PUBLIC
  builtin_interfaces
  geometry_msgs
  message_filters
  rclcpp
  rclcpp_action
  tf2
  tf2_msgs
)

I got the following deprecation warning when I built it.

CMake Deprecation Warning at /workspaces/ros2/install/ament_cmake_target_dependencies/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:89 (message):
  ament_target_dependencies() is deprecated.  Use target_link_libraries()
  with modern CMake targets instead.  Try replacing this call with:

    target_link_libraries(tf2_ros PUBLIC
      ${builtin_interfaces_TARGETS}
      ${geometry_msgs_TARGETS}
      ${tf2_msgs_TARGETS}
      message_filters::message_filters
      rclcpp::rclcpp
      rclcpp_action::rclcpp_action
      tf2::tf2
    )

Call Stack (most recent call first):
  CMakeLists.txt:45 (ament_target_dependencies)

The suggested target_link_libraries() call matches the real call (minus a difference in sorting)
https://github.com/ros2/geometry2/blob/d60e39d663e21d2e426a2a7ff3e3d266df6f8c9a/tf2_ros/CMakeLists.txt#L37-L44

#292

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.

1 participant