Skip to content

Commit

Permalink
Warn if ccache is not configured for precompiled headers
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Oct 8, 2023
1 parent 90b395d commit a5ea142
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a5ea142

Please sign in to comment.