From 09169cb1b55c2403b3bd8aa2d62d938370ed781f Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Fri, 2 Oct 2026 16:53:09 +0900 Subject: [PATCH] Remove ament_export_include_directories and ament_export_libraries calls These packages already call ament_export_targets(), so the old-style CMake variable exports are redundant. rclcpp_action and rclcpp_lifecycle relied on the old-style rclcpp_INCLUDE_DIRS variable to give cppcheck include hints. Take the include directories from the rclcpp::rclcpp target instead so the hint keeps working. Fixes ros2/rclcpp#3285 Co-Authored-By: Claude Fable 5.1 Signed-off-by: Tomoya Fujita --- rclcpp/CMakeLists.txt | 4 ---- rclcpp_action/CMakeLists.txt | 7 ++----- rclcpp_components/CMakeLists.txt | 4 ---- rclcpp_lifecycle/CMakeLists.txt | 7 ++----- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/rclcpp/CMakeLists.txt b/rclcpp/CMakeLists.txt index ac7db1af6e..754d095521 100644 --- a/rclcpp/CMakeLists.txt +++ b/rclcpp/CMakeLists.txt @@ -238,10 +238,6 @@ install( RUNTIME DESTINATION bin ) -# Export old-style CMake variables -ament_export_include_directories("include/${PROJECT_NAME}") -ament_export_libraries(${PROJECT_NAME}) - # Export modern CMake targets ament_export_targets(${PROJECT_NAME}) diff --git a/rclcpp_action/CMakeLists.txt b/rclcpp_action/CMakeLists.txt index 4eefd6af2d..37084c9728 100644 --- a/rclcpp_action/CMakeLists.txt +++ b/rclcpp_action/CMakeLists.txt @@ -64,10 +64,6 @@ install( RUNTIME DESTINATION bin ) -# Export old-style CMake variables -ament_export_include_directories("include/${PROJECT_NAME}") -ament_export_libraries(${PROJECT_NAME}) - # Export modern CMake targets ament_export_targets(${PROJECT_NAME}) @@ -77,7 +73,8 @@ if(BUILD_TESTING) find_package(ament_cmake_gtest REQUIRED) find_package(ament_lint_auto REQUIRED) # Give cppcheck hints about macro definitions coming from outside this package - set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS}) + get_target_property(rclcpp_include_dirs rclcpp::rclcpp INTERFACE_INCLUDE_DIRECTORIES) + set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_include_dirs}) ament_lint_auto_find_test_dependencies() add_subdirectory(test/benchmark) diff --git a/rclcpp_components/CMakeLists.txt b/rclcpp_components/CMakeLists.txt index e4bd0c71cb..e9d5924703 100644 --- a/rclcpp_components/CMakeLists.txt +++ b/rclcpp_components/CMakeLists.txt @@ -167,10 +167,6 @@ install( DESTINATION share/${PROJECT_NAME} ) -# Export old-style CMake variables -ament_export_include_directories("include/${PROJECT_NAME}") -ament_export_libraries(component_manager) - # Export modern CMake targets ament_export_targets(export_${PROJECT_NAME}) diff --git a/rclcpp_lifecycle/CMakeLists.txt b/rclcpp_lifecycle/CMakeLists.txt index b625194817..0515296b96 100644 --- a/rclcpp_lifecycle/CMakeLists.txt +++ b/rclcpp_lifecycle/CMakeLists.txt @@ -58,7 +58,8 @@ install(DIRECTORY include/ if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # Give cppcheck hints about macro definitions coming from outside this package - set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS}) + get_target_property(rclcpp_include_dirs rclcpp::rclcpp INTERFACE_INCLUDE_DIRECTORIES) + set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rclcpp_include_dirs}) list(APPEND AMENT_LINT_AUTO_EXCLUDE "ament_cmake_cppcheck") ament_lint_auto_find_test_dependencies() @@ -185,10 +186,6 @@ if(BUILD_TESTING) endif() endif() -# Export old-style CMake variables -ament_export_include_directories("include/${PROJECT_NAME}") -ament_export_libraries(${PROJECT_NAME}) - # Export modern CMake targets ament_export_targets(${PROJECT_NAME})