Skip to content

Commit 464c3d7

Browse files
clalancetteAlberto Soragna
authored andcommitted
Update all rclcpp packages to C++17. (ros2#2121)
The main reason to do this is so that we can compile rclcpp with the clang static analyzer. As of clang++-14 (what is in Ubuntu 22.04), the default still seems to be C++14, so we need to specify C++17 so that new things in the rclcpp headers work properly. Further, due to reasons I don't fully understand, I needed to set CMAKE_CXX_STANDARD_REQUIRED in order for clang to really use that version. So set this as well. Signed-off-by: Chris Lalancette <[email protected]>
1 parent 825f956 commit 464c3d7

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

rclcpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ find_package(tracetools REQUIRED)
2525
# Default to C++17
2626
if(NOT CMAKE_CXX_STANDARD)
2727
set(CMAKE_CXX_STANDARD 17)
28+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2829
endif()
2930
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
3031
# About -Wno-sign-conversion: With Clang, -Wconversion implies -Wsign-conversion. There are a number of

rclcpp_action/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ find_package(rcl_action REQUIRED)
99
find_package(rcpputils REQUIRED)
1010
find_package(rosidl_runtime_c REQUIRED)
1111

12-
# Default to C++14
12+
# Default to C++17
1313
if(NOT CMAKE_CXX_STANDARD)
14-
set(CMAKE_CXX_STANDARD 14)
14+
set(CMAKE_CXX_STANDARD 17)
15+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1516
endif()
1617
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1718
add_compile_options(

rclcpp_components/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ cmake_minimum_required(VERSION 3.5)
22

33
project(rclcpp_components)
44

5-
# Default to C++14
5+
# Default to C++17
66
if(NOT CMAKE_CXX_STANDARD)
7-
set(CMAKE_CXX_STANDARD 14)
7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
89
endif()
910
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1011
add_compile_options(

rclcpp_lifecycle/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ cmake_minimum_required(VERSION 3.5)
22

33
project(rclcpp_lifecycle)
44

5-
# Default to C++14
5+
# Default to C++17
66
if(NOT CMAKE_CXX_STANDARD)
7-
set(CMAKE_CXX_STANDARD 14)
7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
89
endif()
910
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1011
add_compile_options(-Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual)

0 commit comments

Comments
 (0)