Skip to content

Commit dd6a166

Browse files
committed
fix: adjust C++ standard and compiler flags for Apple Clang
Signed-off-by: Dhruv Patel <[email protected]>
1 parent 920dff0 commit dd6a166

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

nav2_mppi_controller/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
cmake_minimum_required(VERSION 3.5)
22
project(nav2_mppi_controller)
33

4+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
5+
# Use C++20 on Apple Clang to support Concepts natively and avoid -fconcepts
6+
set(CMAKE_CXX_STANDARD 20)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_CXX_EXTENSIONS OFF) # Use -std=c++20, not -std=gnu++20
9+
endif()
10+
411
find_package(ament_cmake REQUIRED)
512
find_package(angles REQUIRED)
613
find_package(backward_ros REQUIRED)
@@ -83,7 +90,12 @@ add_library(mppi_critics SHARED
8390
src/critics/twirling_critic.cpp
8491
src/critics/velocity_deadband_critic.cpp
8592
)
86-
target_compile_options(mppi_critics PUBLIC -fconcepts -O3)
93+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
94+
# Apple Clang: use C++20 and optimization, omit -fconcepts
95+
target_compile_options(mppi_critics PUBLIC -O3)
96+
else()
97+
target_compile_options(mppi_critics PUBLIC -fconcepts -O3)
98+
endif()
8799
target_include_directories(mppi_critics
88100
PUBLIC
89101
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"

0 commit comments

Comments
 (0)