Use sccache on Windows (#4678)

* build: support sccache and windows
This commit is contained in:
nerix 2023-06-11 12:31:04 +02:00 committed by GitHub
parent 4361790fbd
commit a045d3ee81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 3 deletions

View file

@ -134,6 +134,16 @@ jobs:
"C2_CONAN_CACHE_SUFFIX=$(if ($Env:C2_BUILD_WITH_QT6 -eq "on") { "-QT6" } else { "`" })" >> "$Env:GITHUB_ENV"
shell: powershell
- name: Setup sccache (Windows)
# sccache v0.5.3
uses: nerixyz/ccache-action@9a7e8d00116ede600ee7717350c6594b8af6aaa5
if: startsWith(matrix.os, 'windows')
with:
variant: sccache
key: sccache-build-${{ matrix.os }}-${{ matrix.qt-version }}-${{ matrix.skip-crashpad }}
restore-keys: |
sccache-build-${{ matrix.os }}-${{ matrix.qt-version }}
- name: Cache conan packages (Windows)
if: startsWith(matrix.os, 'windows')
uses: actions/cache@v3

3
.gitignore vendored
View file

@ -121,3 +121,6 @@ resources/resources_autogenerated.qrc
# Leftovers from running `aqt install`
aqtinstall.log
# sccache (CI)
.sccache

View file

@ -21,6 +21,8 @@
- Dev: Replace our QObjectRef class with Qt's QPointer class. (#4666)
- Dev: Fixed warnings about QWidgets already having a QLayout. (#4672)
- Dev: Fixed undefined behavior when loading non-existant credentials. (#4673)
- Dev: Added support for compiling with `sccache`. (#4678)
- Dev: Added `sccache` in Windows CI. (#4678)
## 2.4.4

View file

@ -42,9 +42,28 @@ else()
endif()
find_program(CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
message("Using ${CCACHE_PROGRAM} for speeding up build")
find_program(SCCACHE_PROGRAM sccache)
if (SCCACHE_PROGRAM)
set(_compiler_launcher ${SCCACHE_PROGRAM})
elseif (CCACHE_PROGRAM)
set(_compiler_launcher ${CCACHE_PROGRAM})
endif ()
if (_compiler_launcher)
set(CMAKE_CXX_COMPILER_LAUNCHER "${_compiler_launcher}" CACHE STRING "CXX compiler launcher")
message(STATUS "Using ${_compiler_launcher} for speeding up build")
if (MSVC)
# /Zi can't be used with (s)ccache
# Use /Z7 instead (debug info in object files)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif()
endif()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/cmake/GIT.cmake)