Skip to content

Commit

Permalink
Due to the introduction of precompiled headers, ccache builds require…
Browse files Browse the repository at this point in the history
… setting 'ccache -set-config sloppiness=pch_defines,time_macros'
  • Loading branch information
rouault committed Dec 1, 2024
1 parent 2ef66b0 commit 075ea95
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .ci/ogc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 3 additions & 0 deletions .docker/docker-qgis-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
##############################
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/windows-qt6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ jobs:
key: build-ccache-win-qt6-unity # 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: |
Expand Down
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions ms-windows/mingw/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 075ea95

Please sign in to comment.