Permalink
Browse files

Default to ccache with cmake

CCache helps build speed a fair bit, so use that by default (if
available)
  • Loading branch information...
JonnyH committed Nov 27, 2017
1 parent 7191138 commit dc216471a5e7b91420844a7d39fb89a3d34aa633
Showing with 20 additions and 2 deletions.
  1. +2 −2 .travis.yml
  2. +2 −0 CMakeLists.txt
  3. +16 −0 cmake/ccache.cmake
View
@@ -18,7 +18,7 @@ matrix:
packages:
- g++-5
env:
- MATRIX_ENV="PASS=build CXX='ccache g++-5' CC='ccache gcc-5' BUILD_TYPE=RelWithDebInfo"
- MATRIX_ENV="PASS=build CXX='g++-5' CC='gcc-5' BUILD_TYPE=RelWithDebInfo"
- os: linux
addons:
apt:
@@ -27,7 +27,7 @@ matrix:
packages:
- clang-4.0
env:
- MATRIX_ENV="PASS=build CXX='ccache clang++-4.0' CC='ccache clang-4.0' BUILD_TYPE=RelWithDebInfo"
- MATRIX_ENV="PASS=build CXX='clang++-4.0' CC='clang-4.0' BUILD_TYPE=RelWithDebInfo"
- os: linux
addons:
apt:
View
@@ -8,6 +8,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(ccache)
# check compiler
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCCompilerFlag)
View
@@ -0,0 +1,16 @@
find_program(CCACHE ccache)
option(ENABLE_CCACHE "Use CCache build object caching" ON)
if(CCACHE AND ENABLE_CCACHE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
# Clang doesn't like 'unused' arguments, such as when ccache still passed through the '-I' options while requesting no preprocessor.
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
endif()
if (${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
endif()
endif()

0 comments on commit dc21647

Please sign in to comment.