use CMAKE_X_STANDARD and check compiler rather than platform

This commit is contained in:
Mikael Arguedas 2017-06-15 13:48:42 -07:00
parent f396ff2bac
commit 756ef6886d
2 changed files with 17 additions and 8 deletions

View file

@ -12,10 +12,17 @@ find_package(rosidl_generator_cpp REQUIRED)
find_package(rosidl_typesupport_c REQUIRED) find_package(rosidl_typesupport_c REQUIRED)
find_package(rosidl_typesupport_cpp REQUIRED) find_package(rosidl_typesupport_cpp REQUIRED)
if(WIN32) # Default to C++14
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") if(NOT CMAKE_CXX_STANDARD)
else() set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Wpedantic") endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# we dont use add_compile_options with pedantic in message packages
# because the Python C extensions dont comply with it
# TODO(mikaelarguedas) change to add_compile_options
# once this is not a message package anymore
# https://github.com/ros2/system_tests/issues/191
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif() endif()
include_directories(include) include_directories(include)

View file

@ -2,10 +2,12 @@ cmake_minimum_required(VERSION 3.5)
project(rclcpp_lifecycle) project(rclcpp_lifecycle)
if(WIN32) # Default to C++14
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") if(NOT CMAKE_CXX_STANDARD)
else() set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Wpedantic") endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif() endif()
find_package(ament_cmake REQUIRED) find_package(ament_cmake REQUIRED)