From fe380d7627a0cb1ed274d95bc36f678fe2b3566d Mon Sep 17 00:00:00 2001 From: "Tomoya.Fujita" Date: Sun, 5 Jul 2026 13:58:54 +0900 Subject: [PATCH 1/2] use C++ 20 in default. Signed-off-by: Tomoya.Fujita --- rclcpp_action/CMakeLists.txt | 4 ++-- rclcpp_components/CMakeLists.txt | 4 ++-- rclcpp_lifecycle/CMakeLists.txt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rclcpp_action/CMakeLists.txt b/rclcpp_action/CMakeLists.txt index d07031d5f4..4852e01729 100644 --- a/rclcpp_action/CMakeLists.txt +++ b/rclcpp_action/CMakeLists.txt @@ -10,9 +10,9 @@ find_package(rcl_action REQUIRED) find_package(rcpputils REQUIRED) find_package(rosidl_runtime_c REQUIRED) -# Default to C++17 +# Default to C++20 if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/rclcpp_components/CMakeLists.txt b/rclcpp_components/CMakeLists.txt index 9fdcf55511..f91c6bc803 100644 --- a/rclcpp_components/CMakeLists.txt +++ b/rclcpp_components/CMakeLists.txt @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.20) project(rclcpp_components) -# Default to C++17 +# Default to C++20 if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/rclcpp_lifecycle/CMakeLists.txt b/rclcpp_lifecycle/CMakeLists.txt index 3eb78ad51f..4a983cdbdc 100644 --- a/rclcpp_lifecycle/CMakeLists.txt +++ b/rclcpp_lifecycle/CMakeLists.txt @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.20) project(rclcpp_lifecycle) -# Default to C++17 +# Default to C++20 if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") From 74927ff49dd8e141eb889139683f11cea3c9f76e Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Cordero Date: Mon, 6 Jul 2026 13:22:03 +0200 Subject: [PATCH 2/2] use ament_cmake_ros_core Signed-off-by: Alejandro Hernandez Cordero --- rclcpp_action/CMakeLists.txt | 9 ++++----- rclcpp_action/package.xml | 1 + rclcpp_components/CMakeLists.txt | 14 ++++++++------ rclcpp_components/package.xml | 1 + rclcpp_lifecycle/CMakeLists.txt | 9 ++++----- rclcpp_lifecycle/package.xml | 1 + 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/rclcpp_action/CMakeLists.txt b/rclcpp_action/CMakeLists.txt index 4852e01729..ece59d7726 100644 --- a/rclcpp_action/CMakeLists.txt +++ b/rclcpp_action/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.20) project(rclcpp_action) find_package(ament_cmake_ros REQUIRED) +find_package(ament_cmake_ros_core REQUIRED) find_package(action_msgs REQUIRED) find_package(rclcpp REQUIRED) find_package(rcl REQUIRED) @@ -10,11 +11,6 @@ find_package(rcl_action REQUIRED) find_package(rcpputils REQUIRED) find_package(rosidl_runtime_c REQUIRED) -# Default to C++20 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options( -Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual @@ -42,6 +38,9 @@ target_link_libraries(${PROJECT_NAME} PUBLIC rcl_action::rcl_action rclcpp::rclcpp rosidl_runtime_c::rosidl_runtime_c + # Note we link public on purpose, as we want to export + # the used C++ version as minimum to all consuming packages + ament_cmake_ros_core::ament_ros_defaults ) target_link_libraries(${PROJECT_NAME} PRIVATE rcpputils::rcpputils diff --git a/rclcpp_action/package.xml b/rclcpp_action/package.xml index 4f5f1caea1..b4cdcdc8d1 100644 --- a/rclcpp_action/package.xml +++ b/rclcpp_action/package.xml @@ -18,6 +18,7 @@ rosidl_runtime_c + ament_cmake_ros_core rosidl_runtime_c action_msgs diff --git a/rclcpp_components/CMakeLists.txt b/rclcpp_components/CMakeLists.txt index f91c6bc803..e4bd0c71cb 100644 --- a/rclcpp_components/CMakeLists.txt +++ b/rclcpp_components/CMakeLists.txt @@ -2,11 +2,6 @@ cmake_minimum_required(VERSION 3.20) project(rclcpp_components) -# Default to C++20 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options( -Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual @@ -15,6 +10,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() find_package(ament_cmake_ros REQUIRED) +find_package(ament_cmake_ros_core REQUIRED) find_package(ament_index_cpp REQUIRED) find_package(class_loader REQUIRED) find_package(composition_interfaces REQUIRED) @@ -30,7 +26,10 @@ target_include_directories(component INTERFACE "$") target_link_libraries(component INTERFACE class_loader::class_loader - rclcpp::rclcpp) + rclcpp::rclcpp + # Note we link public on purpose, as we want to export + # the used C++ version as minimum to all consuming packages + ament_cmake_ros_core::ament_ros_defaults) add_library( component_manager @@ -45,6 +44,9 @@ target_link_libraries(component_manager PUBLIC composition_interfaces::composition_interfaces rclcpp::rclcpp rmw::rmw + # Note we link public on purpose, as we want to export + # the used C++ version as minimum to all consuming packages + ament_cmake_ros_core::ament_ros_defaults ) target_link_libraries(component_manager PRIVATE ament_index_cpp::ament_index_cpp diff --git a/rclcpp_components/package.xml b/rclcpp_components/package.xml index ddb961a7d2..5833723eca 100644 --- a/rclcpp_components/package.xml +++ b/rclcpp_components/package.xml @@ -22,6 +22,7 @@ rcpputils rmw + ament_cmake_ros_core ament_index_cpp class_loader composition_interfaces diff --git a/rclcpp_lifecycle/CMakeLists.txt b/rclcpp_lifecycle/CMakeLists.txt index 4a983cdbdc..e96278e2f0 100644 --- a/rclcpp_lifecycle/CMakeLists.txt +++ b/rclcpp_lifecycle/CMakeLists.txt @@ -2,16 +2,12 @@ cmake_minimum_required(VERSION 3.20) project(rclcpp_lifecycle) -# Default to C++20 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual) endif() find_package(ament_cmake_ros REQUIRED) +find_package(ament_cmake_ros_core REQUIRED) find_package(lifecycle_msgs REQUIRED) find_package(rcl REQUIRED) find_package(rclcpp REQUIRED) @@ -41,6 +37,9 @@ target_link_libraries(${PROJECT_NAME} rcl_lifecycle::rcl_lifecycle rcutils::rcutils rosidl_typesupport_cpp::rosidl_typesupport_cpp + # Note we link public on purpose, as we want to export + # the used C++ version as minimum to all consuming packages + ament_cmake_ros_core::ament_ros_defaults ) # Causes the visibility macros to use dllexport rather than dllimport, diff --git a/rclcpp_lifecycle/package.xml b/rclcpp_lifecycle/package.xml index 12b80fe0e1..35eb936835 100644 --- a/rclcpp_lifecycle/package.xml +++ b/rclcpp_lifecycle/package.xml @@ -16,6 +16,7 @@ ament_cmake_ros + ament_cmake_ros_core lifecycle_msgs rcl rclcpp