From 4cbba1ff92ef4b29dee6dbc2a37fc0b77d348393 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Wed, 19 Apr 2017 14:48:40 +0200 Subject: [PATCH] [CMake] Check for required ccache config. --- CMakeLists.txt | 1 + scripts/cmake/CCacheSetup.cmake | 28 ++++++++++++++++++++++++++++ scripts/cmake/Find.cmake | 10 +--------- 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 scripts/cmake/CCacheSetup.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 50eaa95913f..5faa2f647ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ include(scripts/cmake/Functions.cmake) include(scripts/cmake/CMakeSetup.cmake) include(scripts/cmake/CompilerSetup.cmake) include(scripts/cmake/Find.cmake) +include(scripts/cmake/CCacheSetup.cmake) include(scripts/cmake/SubmoduleSetup.cmake) include(scripts/cmake/ProjectSetup.cmake) include(scripts/cmake/DocumentationSetup.cmake) diff --git a/scripts/cmake/CCacheSetup.cmake b/scripts/cmake/CCacheSetup.cmake new file mode 100644 index 00000000000..ddac17905d4 --- /dev/null +++ b/scripts/cmake/CCacheSetup.cmake @@ -0,0 +1,28 @@ +if(NOT CCACHE_TOOL_PATH) + return() +endif() + +# Set ccache as the compiler launcher +set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) +set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + +if(COMPILER_IS_CLANG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") +endif() + +# Check ccache pre-compiled headers config +execute_process(COMMAND ${CCACHE_TOOL_PATH} --print-config + OUTPUT_VARIABLE CCACHE_CONFIG + ERROR_VARIABLE CCACHE_CONFIG +) + +# Regex should be "sloppiness.*time_macros.*pch_defines.*" but due to bug fixed +# in https://ccache.samba.org/releasenotes.html#_ccache_3_2_5 we have to leave +# out pch_defines. Ubuntu 16.04 comes with ccache 3.2.4 ... +string(REGEX MATCH "sloppiness.*time_macros.*" + COTIRE_CCACHE_CONFIG ${CCACHE_CONFIG} +) + +if(NOT COTIRE_CCACHE_CONFIG) + message(FATAL_ERROR "CCache not configured! You must set sloppiness to pch_defines,time_macros. See https://docs.opengeosys.org/docs/devguide/advanced/using-ccache") +endif() diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake index d2baee31e8d..f482c13d647 100644 --- a/scripts/cmake/Find.cmake +++ b/scripts/cmake/Find.cmake @@ -54,15 +54,7 @@ find_program(CURL_TOOL_PATH curl DOC "The curl-tool") find_program(S3CMD_TOOL_PATH s3cmd DOC "S3cmd tool for uploading to Amazon S3") -## CCache -find_program(CCACHE_FOUND ccache) -if(CCACHE_FOUND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) - if(COMPILER_IS_CLANG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") - endif() -endif(CCACHE_FOUND) +find_program(CCACHE_TOOL_PATH ccache) # Tools for web find_program(VTKJS_CONVERTER vtkDataConverter -- GitLab