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:
Esteve Fernandez 2017-06-16 22:23:59 +02:00 committed by Mikael Arguedas
parent 21fff528e1
commit 0f2519944a
2 changed files with 26 additions and 9 deletions

View file

@ -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