Due to the introduction of precompiled headers, ccache builds require setting 'ccache -set-config sloppiness=pch_defines,time_macros'

This commit is contained in:
Even Rouault 2024-12-01 16:37:32 +01:00 committed by Nyall Dawson
parent 7b7cab76b2
commit ddaca73dbf
6 changed files with 38 additions and 2 deletions

View File

@ -13,6 +13,9 @@ ccache -M 2.0G
# export CCACHE_LOGFILE=/tmp/cache.debug
ccache -z
# To make ccache work properly with precompiled headers
ccache --set-config sloppiness=pch_defines,time_macros
cmake -GNinja \
-DUSE_CCACHE=ON \
-DWITH_QUICK=OFF \

View File

@ -18,6 +18,9 @@ ccache -M 2.0G
# export CCACHE_LOGFILE=/tmp/cache.debug
ccache -z
# To make ccache work properly with precompiled headers
ccache --set-config sloppiness=pch_defines,time_macros
##############################
# Variables for output styling
##############################

View File

@ -108,6 +108,8 @@ jobs:
mkdir -p ${CCACHE_DIR}
brew install ccache
ccache --set-config=max_size=2.0G
# To make ccache work properly with precompiled headers
ccache --set-config sloppiness=pch_defines,time_macros
ccache -s
- name: Run cmake

View File

@ -53,6 +53,12 @@ jobs:
key: build-ccache-win64-qt6-${{ github.event.pull_request.base.ref || github.ref_name }}
save: ${{ github.event_name == 'push' }}
- name: 🛍️ Tune ccache configuration
shell: bash
run: |
# To make ccache work properly with precompiled headers
ccache --set-config sloppiness=pch_defines,time_macros
- name: 🌱 Install dependencies and generate project files
shell: bash
run: |

View File

@ -125,9 +125,28 @@ option(USE_CCACHE "Use ccache" ON)
if (USE_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)
message(STATUS "ccache found")
execute_process(COMMAND ccache --help OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CCACHE_HELP)
execute_process(COMMAND ccache --get-config sloppiness OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CCACHE_SLOPPINESS)
string(FIND "${CCACHE_SLOPPINESS}" "pch_defines" fpch_defines_found_index)
string(FIND "${CCACHE_SLOPPINESS}" "time_macros" time_macros_found_index)
# Detect if we have ccache >= 4.8 which accepts passing configuration settings when invoking the compiler
string(FIND "${CCACHE_HELP}" "ccache [KEY=VALUE ...] compiler" ccache_key_value_found_index)
if (ccache_key_value_found_index EQUAL -1 )
if (fpch_defines_found_index EQUAL -1 OR time_macros_found_index EQUAL -1)
message(FATAL_ERROR "The use of precompiled headers only work if the ccache 'sloppiness' settings contains 'pch_defines' and 'time_macros'. Consider running 'ccache --set-config sloppiness=pch_defines,time_macros' to define them")
endif()
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
else()
if (fpch_defines_found_index EQUAL -1 OR time_macros_found_index EQUAL -1)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache sloppiness=pch_defines,time_macros")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache sloppiness=pch_defines,time_macros")
else()
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()
endif()
endif(CCACHE_FOUND)
endif(USE_CCACHE)

View File

@ -67,6 +67,9 @@ fi
installroot="$BUILDDIR/dist"
installprefix="$installroot/usr/$arch-w64-mingw32/sys-root/mingw"
# To make ccache work properly with precompiled headers
ccache --set-config sloppiness=pch_defines,time_macros
# Cleanup
rm -rf "$installroot"