From 21146d0420d1e8692ff8fbc94c46496978a40f64 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Mon, 19 Sep 2016 21:12:40 +0200 Subject: [PATCH] ccache: more robust check if config sloppiness is set to "pch_defines,time_macros" --- CMake/cotire.cmake | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 5cbcbaf..a37ba22 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -1856,10 +1856,31 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) endif() get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR _launcher MATCHES "ccache") - if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros|pch_defines") - set (${_msgVar} - "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." - PARENT_SCOPE) + if (DEFINED ENV{CCACHE_SLOPPINESS}) + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + set (${_msgVar} + "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() + else() + if (_launcher MATCHES "ccache") + get_filename_component(_ccacheExe "${_launcher}" REALPATH) + else() + get_filename_component(_ccacheExe "${CMAKE_${_language}_COMPILER}" REALPATH) + endif() + execute_process( + COMMAND "${_ccacheExe}" "--print-config" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + if (_result OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") + set (${_msgVar} + "ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() endif() endif() if (APPLE)