Repository navigation
Deprecate ament_target_dependencies() - #572
Merged
Merged
Conversation
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
sloretz
marked this pull request as ready for review
March 26, 2025 20:31
christophebedard
approved these changes
Apr 5, 2025
christophebedard
left a comment
Member
There was a problem hiding this comment.
That's probably the most helpful deprecation warning I've seen 👏
Contributor
Author
|
Pulls: #572 |
cottsay
approved these changes
Apr 5, 2025
1 task
Rayman
added a commit
to ros-perception/perception_pcl
that referenced
this pull request
May 22, 2025
`ament_target_dependencies` is deprecated rolling, so we should convert all usages to `target_link_libraries`. See also the following discussion: ament/ament_cmake#572
SteveMacenski
pushed a commit
to ros-perception/perception_pcl
that referenced
this pull request
May 22, 2025
`ament_target_dependencies` is deprecated rolling, so we should convert all usages to `target_link_libraries`. See also the following discussion: ament/ament_cmake#572
This was referenced Aug 21, 2025
AntoBrandi
pushed a commit
to AntoBrandi/perception_pcl
that referenced
this pull request
Aug 26, 2025
`ament_target_dependencies` is deprecated rolling, so we should convert all usages to `target_link_libraries`. See also the following discussion: ament/ament_cmake#572
jcfurey
pushed a commit
to jcfurey/ouster-ros
that referenced
this pull request
May 17, 2026
`ament_target_dependencies()` is being deprecated in newer ROS 2 distros (ament/ament_cmake#572, merged Apr 2025). In rolling/lyrical, the ament_cmake metapackage no longer hard-depends on ament_cmake_target_dependencies — it's now only a build_export_depend. Consumers that still call `ament_target_dependencies()` need to opt in by find_package'ing the dedicated package and declaring it as a buildtool_depend so rosdep installs it. This unblocks the lyrical Docker build: CMake Error at CMakeLists.txt:103 (ament_target_dependencies): Unknown CMake command \"ament_target_dependencies\". Migration to direct \`target_link_libraries(target pkg::pkg)\` / \`\${pkg_TARGETS}\` is the longer-term fix but out of scope here.
wentasah
added a commit
to wentasah/ros2_console_tools
that referenced
this pull request
Aug 17, 2026
ament_target_dependencies is deprecated [1] and was removed in ROS
Lyrical [2]. This commit replaces calls to ament_target_dependencies
with plain CMake command target_link_libraries as suggested in [1].
While [1] suggested to replace interface packages with ${xxx_TARGETS},
this is not necessary since [3]. Therefore, this commit replaces every
"xxx" package with "xxx::xxx" target.
Compilation was tested under ROS Jazzy and Lyrical.
[1]: ament/ament_cmake#572
[2]: ament/ament_cmake#583
[3]: ros2/rosidl#947
robwoolley
added a commit
to robwoolley/meta-ros
that referenced
this pull request
Sep 2, 2026
…pendencies) Root-caused via web search after a validation rebuild showed the earlier ament-cmake-target-dependencies DEPENDS fix (260c780) wasn't enough on its own: aruco-ros still hit "Unknown CMake command \"ament_target_dependencies\"" even though the package's cmake config was now correctly staged into its sysroot (confirmed on disk). Turns out staging the files was necessary but not sufficient. In lyrical/rolling, the ament_cmake metapackage no longer hard-depends on ament_cmake_target_dependencies -- it's only a build_export_depend now (see ament/ament_cmake#572) -- so plain find_package(ament_cmake REQUIRED) no longer transitively find_package()'s (and thus include()'s) ament_cmake_target_dependencies-extras.cmake the way it did in older distros, which is what actually defines the ament_target_dependencies() macro. Upstream's own fix is for each consuming package's CMakeLists.txt to find_package() it directly, but most of the ROS ecosystem hasn't been updated for that breaking change yet. Rather than patch 25+ individual upstream CMakeLists.txt files, inject it globally via CMake's CMAKE_PROJECT_INCLUDE mechanism (runs right after each project() call, in full script context) pointing at a new ament_target_dependencies_compat.cmake next to this bbclass, which just does find_package(ament_cmake_target_dependencies QUIET) -- a safe no-op for packages that don't need it. Referencing that file's path correctly needed a second fix: a bbclass's own d.getVar('FILE') reflects whichever recipe is currently being parsed, not the class's own file location, so a first attempt using os.path.dirname(d.getVar('FILE')) resolved to (and appended) "<consuming-recipe's-own-dir>/ament_target_dependencies_compat.cmake" for every recipe -- verified wrong via bitbake-getvar before it was ever built. Fixed by capturing LAYERDIR in this layer's own layer.conf (as ROS2_LYRICAL_LAYER_DIR, immediate-expanded so it's frozen at the one point where LAYERDIR is actually this layer's root) instead of trying to derive it from inside the class. Re-verified via bitbake-getvar that EXTRA_OECMAKE now carries the correct absolute path. Also force-cleaned sstate (bitbake -c cleansstate) for ament-cmake(-native), rosidl-cmake(-native), generate-parameter-library(-native), and phidgets-api: the validation rebuild revealed that recipes which had *always* succeeded earlier in the session (unlike the always-failing consumers) were silently reusing stale pre-fix sstate artifacts -- e.g. rosidl-cmake-native's do_configure log was dated Aug 22, six days before the rosidl-adapter-native DEPENDS fix -- masking that fix's effect entirely. Confirmed real: autoware-planning-msgs still had zero rosidl_adapter files staged anywhere in its sysroot despite the fix being correctly present in rosidl-cmake's own DEPENDS. Co-Authored-By: Claude Sonnet 5 <[email protected]>
yishinli
added a commit
to yishinli/abb_ros2
that referenced
this pull request
Oct 26, 2026
ament_target_dependencies() was deprecated in Kilted (ament/ament_cmake#572) and removed in Rolling / Lyrical (ament/ament_cmake#614), so abb_hardware_interface, abb_rws_client and the abb_bringup tests fail to configure with "Unknown CMake command". Link the exported CMake targets directly instead. abb_hardware_interface only exports old-style variables, so abb_rws_client uses abb_hardware_interface_LIBRARIES / _INCLUDE_DIRS for it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are no more uses of
ament_target_dependencies()in the core 🎉Requires #571Requires ros2/system_tests#566This PR deprecates
ament_target_dependencies()in favor oftarget_link_libraries(). This PR also adds a deprecation warning that suggests atarget_link_libraries()call to be used instead.For example, I inserted a call to
ament_target_dependenciesinto my local copy oftf2_ros:I got the following deprecation warning when I built it.
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