Fix ccache for Windows in GitHub Actions

- Add TrackFileAccess=false to CMAKE_VS_GLOBALS in ccache-msvc.cmake
  to prevent MSBuild from tracking ccache files as build outputs
- Move Windows ccache directory to %TEMP% to avoid Visual Studio's
  file tracking triggering unnecessary rebuilds
- Update cache action path to use platform-specific locations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Eric Kilmer
2026-01-24 09:26:48 -05:00
parent 0664b5c545
commit 8243a7b4b4
2 changed files with 9 additions and 6 deletions
+8 -6
View File
@@ -69,7 +69,7 @@ jobs:
- name: Update the cache (ccache)
uses: actions/cache@v5
with:
path: "${{ github.workspace }}/ccache"
path: ${{ runner.os == 'Windows' && env.TEMP || github.workspace }}/ccache
key: ${{ env.CACHE_KEY }}_ccache_${{ env.CACHE_TIMESTAMP }}
restore-keys: |
${{ env.CACHE_KEY }}_ccache_
@@ -80,14 +80,16 @@ jobs:
run: |
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ccache")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_BASEDIR=${CMAKE_CURRENT_SOURCE_DIR}\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/ccache\n")
if(WIN32)
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=$ENV{TEMP}/ccache\n")
else()
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/ccache\n")
endif()
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESS=true\n")
# Trial and error to get all files in here
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESSLEVEL=10\n")
# This should be multiplied by the number of compilation jobs and be no
# larger than 5G, which is the cache max size
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_MAXSIZE=400M\n")
# Tell CMake to use ccache
# These only work for Ninja/Makefiles, not VS generators
# But harmless to set for all platforms
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_CXX_COMPILER_LAUNCHER=ccache\n")
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_C_COMPILER_LAUNCHER=ccache\n")
# Clear stats before every build
+1
View File
@@ -29,6 +29,7 @@ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedd
set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"TrackFileAccess=false"
"UseMultiToolTask=true"
"DebugInformationFormat=OldStyle"
)