Skip to content

Remove legacy ament_export_include_directories/libraries calls - #3286

Open
akshar27 wants to merge 1 commit into
ros2:rollingfrom
akshar27:fix/remove-legacy-ament-export-calls
Open

akshar27 wants to merge 1 commit into
ros2:rollingfrom
akshar27:fix/remove-legacy-ament-export-calls

Conversation

@akshar27

Copy link
Copy Markdown

Description

Fixes #3285

rclcpp, rclcpp_action, rclcpp_components and rclcpp_lifecycle all already call ament_export_targets() to export modern CMake targets. Per the issue, that makes the old-style ament_export_include_directories() and ament_export_libraries() calls in each package redundant, so this deletes both (and the now-stale "Export old-style CMake variables" comment above them) from all four CMakeLists.txt files.

Something I found while checking this (left untouched, flagging for review)

rclcpp_action/CMakeLists.txt and rclcpp_lifecycle/CMakeLists.txt each still read ${rclcpp_INCLUDE_DIRS} inside a BUILD_TESTING-only block, to give ament_cmake_cppcheck a hint about include directories coming from outside the package:

set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS})

That variable used to be populated by rclcpp's own ament_export_include_directories() call, which this PR removes. I left both usages alone since (a) this is a cppcheck lint hint, not a functional build/link dependency, and (b) it's out of this issue's stated scope (delete the two calls from these four files). If ${rclcpp_INCLUDE_DIRS} does go empty after this change, the practical effect should just be cppcheck losing some macro-origin hints during the ament_lint_auto cppcheck pass in CI, not a build break — but flagging it explicitly in case a maintainer wants it addressed as a follow-up (possibly by pointing at rclcpp_SOURCE_DIR/rclcpp_INCLUDE_DIRECTORIES from the modern target instead, or similar).

Testing

No local ROS 2/colcon build environment was available, so I verified this differently:

  • Confirmed the exact deletions match the issue's instructions precisely (grepped for every ament_export_include_directories/ament_export_libraries call across all four files first, deleted exactly those + the associated stale comment, nothing else).
  • Grepped the whole repo's CMakeLists.txt files for any reference to the old-style variables these calls populate (${rclcpp_INCLUDE_DIRS}, ${rclcpp_LIBRARIES}, and the equivalents for the other three packages) to catch any in-repo consumer that might break — found the two cppcheck-hint usages noted above, nothing else.
  • Ran cmakelint on all four modified files and compared the warning count against the unmodified upstream files: identical (12/0/20/16 respectively) — this change introduces no new lint warnings, all remaining warnings are pre-existing unrelated line-length flags.

This PR was written with the help of Claude Code (Claude Sonnet 5), under my direction and review.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Snzt7njUYkxw4oxYJsENbQ

rclcpp, rclcpp_action, rclcpp_components and rclcpp_lifecycle all
already call ament_export_targets() to export modern CMake targets,
so downstream packages can (and should) link against those targets
instead of using the old-style CMake variables that
ament_export_include_directories() and ament_export_libraries() used
to populate. Delete both calls, and the now-stale 'Export old-style
CMake variables' comment above them, from all four packages'
CMakeLists.txt.

rclcpp_action and rclcpp_lifecycle each still read ${rclcpp_INCLUDE_DIRS}
in a BUILD_TESTING-only block, to give ament_cmake_cppcheck a hint about
include directories coming from outside the package:

    set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS})

Left both alone: this is a cppcheck lint hint, not a functional
build/link dependency, and out of this issue's stated scope (delete the
two calls from these four files). If ${rclcpp_INCLUDE_DIRS} does turn
out to go empty after this change, cppcheck may lose some macro-origin
hints during ament_lint_auto's cppcheck pass; it should not affect the
actual build.

Fixes ros2#3285

Signed-off-by: akshar <akshargothi70@gmail.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Snzt7njUYkxw4oxYJsENbQ
Signed-off-by: akshar <akshargothi70@gmail.com>
@jmachowinski

Copy link
Copy Markdown
Collaborator

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.

Delete ament_export_include_directories() and ament_export_libraries() calls

2 participants