Explicitly set C11 and C++14 via the CMake variables (#141)
* Explicitly set C99 and C++14 via the CMake variables * Enable passing CMAKE_C_STANDARD and CMAKE_CXX_STANDARD externally * Use add_compile_options * Be more specific about the compiler, independent from the OS * Check compiler, not OS. Use add_compile_options instead of CMAKE_C_FLAGS and CMAKE_CXX_FLAGS * add_compile_options() takes a list, not a string * switch to c11 because of redefinition warnings avoid typedef redifinition warning on macos remove todo, compiler come from redefinition of typedef
This commit is contained in:
parent
21fff528e1
commit
0f2519944a
2 changed files with 26 additions and 9 deletions
|
@ -12,9 +12,18 @@ find_package(rosidl_generator_c REQUIRED)
|
|||
|
||||
include_directories(include)
|
||||
|
||||
if(NOT WIN32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra")
|
||||
# Default to C11
|
||||
if(NOT CMAKE_C_STANDARD)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
endif()
|
||||
|
||||
# Default to C++14
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra)
|
||||
endif()
|
||||
|
||||
set(${PROJECT_NAME}_sources
|
||||
|
|
|
@ -11,6 +11,20 @@ find_package(rmw REQUIRED)
|
|||
|
||||
include_directories(include)
|
||||
|
||||
# Default to C11
|
||||
if(NOT CMAKE_C_STANDARD)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
endif()
|
||||
|
||||
# Default to C++14
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
endif()
|
||||
|
||||
set(rcl_lifecycle_sources
|
||||
src/com_interface.c
|
||||
src/default_state_machine.c
|
||||
|
@ -43,12 +57,6 @@ install(TARGETS rcl_lifecycle
|
|||
RUNTIME DESTINATION bin)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
endif()
|
||||
|
||||
find_package(ament_cmake_gtest REQUIRED)
|
||||
find_package(ament_lint_auto REQUIRED)
|
||||
find_package(rcl REQUIRED)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue