From 12c0ec19e0e3e1980204ce112ee34d9e5812633d Mon Sep 17 00:00:00 2001 From: Patrick Beeson Date: Tue, 23 Jun 2020 13:21:21 -0500 Subject: [PATCH] Update CMake to work better with clang (#22) * Update CMake to work better with clang * Add clang compiler CI build * Switch to legacy branch of industrial_ci * Add install of clang-8 for clang compiler CI build * Switch from clang-8 to clang Co-authored-by: Patrick Beeson Co-authored-by: Levi Armstrong --- .travis.yml | 14 ++++++++++- .../cmake/descartes_light_macros.cmake | 24 ++++++++++++++----- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index e04daaac..0e049fea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,12 +32,24 @@ jobs: cache: directories: - $HOME/.ccache + - os: linux + dist: xenial + language: cpp + env: + - ROS_DISTRO="melodic" + - CCACHE_DIR=$HOME/.ccache + - BADGE=xenial-clang-compiler + - ADDITIONAL_DEBS="clang" + - CMAKE_ARGS="-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DENABLE_TESTS=ON" + cache: + directories: + - $HOME/.ccache - os: windows language: cpp env: BADGE=windows install: - - if [ "$TRAVIS_OS_NAME" != "windows" ]; then git clone --quiet --depth=1 https://github.com/ros-industrial/industrial_ci.git .ci_config; fi + - if [ "$TRAVIS_OS_NAME" != "windows" ]; then git clone --quiet --depth=1 https://github.com/ros-industrial/industrial_ci.git .ci_config -b legacy ; fi - | if [ "$TRAVIS_OS_NAME" = "windows" ]; then unset CXX CXX_FOR_BUILD CC CC_FOR_BUILD diff --git a/descartes_light/cmake/descartes_light_macros.cmake b/descartes_light/cmake/descartes_light_macros.cmake index 522dba85..570220e0 100644 --- a/descartes_light/cmake/descartes_light_macros.cmake +++ b/descartes_light/cmake/descartes_light_macros.cmake @@ -39,8 +39,12 @@ macro(descartes_target_compile_options target) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 CXX_FEATURE_FOUND) if (ARG_INTERFACE) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(${target} INTERFACE -Wall -Wextra -Wsuggest-override -Wconversion -Wsign-conversion) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${target} INTERFACE -Wall -Wextra -Wsuggest-override -Wconversion -Wsign-conversion) + else() + target_compile_options(${target} INTERFACE -Wall -Wextra -Winconsistent-missing-override -Wconversion -Wsign-conversion) + endif() target_compile_options(${target} INTERFACE -mno-avx) target_compile_definitions(${target} INTERFACE DESCARTES_BUILDING_LIBRARY=ON) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") @@ -55,8 +59,12 @@ macro(descartes_target_compile_options target) target_compile_features("${target}" INTERFACE cxx_std_11) endif() elseif(ARG_PUBLIC) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(${target} PRIVATE -Wall -Wextra -Wsuggest-override -Wconversion -Wsign-conversion) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${target} PRIVATE -Wall -Wextra -Wsuggest-override -Wconversion -Wsign-conversion) + else() + target_compile_options(${target} PRIVATE -Wall -Wextra -Winconsistent-missing-override -Wconversion -Wsign-conversion) + endif() target_compile_options(${target} PUBLIC -mno-avx) target_compile_definitions(${target} PRIVATE DESCARTES_BUILDING_LIBRARY=ON) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") @@ -72,8 +80,12 @@ macro(descartes_target_compile_options target) target_compile_features(${target} PUBLIC cxx_std_11) endif() elseif(ARG_PRIVATE) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(${target} PRIVATE -Wall -Wextra -Wsuggest-override -Wconversion -Wsign-conversion) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${target} PRIVATE -Wall -Wextra -Wsuggest-override -Wconversion -Wsign-conversion) + else() + target_compile_options(${target} PRIVATE -Wall -Wextra -Winconsistent-missing-override -Wconversion -Wsign-conversion) + endif() target_compile_options(${target} PRIVATE -mno-avx) target_compile_definitions(${target} PRIVATE DESCARTES_BUILDING_LIBRARY=ON) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")