Skip to content

Commit

Permalink
Update CMake to work better with clang (#22)
Browse files Browse the repository at this point in the history
* 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 <pbeeson@traclabs.com>
Co-authored-by: Levi Armstrong <levi.armstrong@gmail.com>
  • Loading branch information
3 people authored Jun 23, 2020
1 parent eb1fe62 commit 12c0ec1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
14 changes: 13 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 18 additions & 6 deletions descartes_light/cmake/descartes_light_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 12c0ec1

Please sign in to comment.