diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-06-30 12:49:47 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-07-13 15:11:12 +0200 |
commit | 6ca7b28e60afdc72d888b4c96fff509568ee3bd5 (patch) | |
tree | 4389f21696583180fe223558d9725c7b7f45ff54 /CMakeLists.txt | |
parent | 92354bdc25d7857b5142da35806a3b2e7bad2b4e (diff) | |
download | qtlocation-mapboxgl-6ca7b28e60afdc72d888b4c96fff509568ee3bd5.tar.gz |
[build] add ccache + Circle CI caching
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d60240cd..a4a6e4d8c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.4) project(mbgl LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) @@ -86,6 +86,34 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") endif() +# Technique from https://crascit.com/2016/04/09/using-ccache-with-cmake/ +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + set(C_LAUNCHER "${CCACHE_PROGRAM}") + set(CXX_LAUNCHER "${CCACHE_PROGRAM}") + configure_file(scripts/launch-c.in launch-c) + configure_file(scripts/launch-cxx.in launch-cxx) + execute_process(COMMAND chmod a+rx "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx") + + if(CMAKE_GENERATOR STREQUAL "Xcode") + # Set Xcode project attributes to route compilation and linking through our scripts + set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx") + set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx") + else() + # Support Unix Makefiles and Ninja + set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx") + endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + # ccache splits up the compile steps, so we end up with unused arguments in some steps. + # Clang also thinks that ccache isn't interactive, so we explicitly need to enable color. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics") + endif() +endif() + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/platform/${MBGL_PLATFORM}/config.cmake) message(ERROR "Can't find config.cmake file for platform ${MBGL_PLATFORM}") endif() |