From a5ea142f34d70aafcbb7e837197e50f5c5038a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 8 Oct 2023 19:26:58 +0200 Subject: [PATCH] Warn if ccache is not configured for precompiled headers --- CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c1190d7b2d..7ec9687957d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -536,6 +536,21 @@ else() # without this compiler messages in `make` backend would be uncolored set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=${BUILD_COLORS}") endif() + if(NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) + execute_process( + COMMAND "${CCACHE_EXECUTABLE}" "--get-config=sloppiness" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + OUTPUT_VARIABLE CCACHE_CONFIGURED_SLOPPINESS OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + if (NOT CCACHE_CONFIGURED_SLOPPINESS MATCHES "pch_defines" OR + NOT CCACHE_CONFIGURED_SLOPPINESS MATCHES "time_macros") + message(WARNING + "ccache: For use with precompiled headers, the setting \"sloppiness\" needs to " + "be set to \"pch_defines,time_macros\". This can be done via the environment variable " + "\"CCACHE_SLOPPINESS=pch_defines,time_macros\" or permanent via " + "\"ccache --set-config=sloppiness=pch_defines,time_macros\".") + endif() + endif() set( CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}" ) set( CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}" ) endif()