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" "C2_CONAN_CACHE_SUFFIX=$(if ($Env:C2_BUILD_WITH_QT6 -eq "on") { "-QT6" } else { "`" })" >> "$Env:GITHUB_ENV"
shell: powershell 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) - name: Cache conan packages (Windows)
if: startsWith(matrix.os, 'windows') if: startsWith(matrix.os, 'windows')
uses: actions/cache@v3 uses: actions/cache@v3

3
.gitignore vendored
View file

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

View file

@ -21,6 +21,8 @@
- Dev: Replace our QObjectRef class with Qt's QPointer class. (#4666) - Dev: Replace our QObjectRef class with Qt's QPointer class. (#4666)
- Dev: Fixed warnings about QWidgets already having a QLayout. (#4672) - Dev: Fixed warnings about QWidgets already having a QLayout. (#4672)
- Dev: Fixed undefined behavior when loading non-existant credentials. (#4673) - 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 ## 2.4.4

View file

@ -42,11 +42,30 @@ else()
endif() endif()
find_program(CCACHE_PROGRAM ccache) find_program(CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM) find_program(SCCACHE_PROGRAM sccache)
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") if (SCCACHE_PROGRAM)
message("Using ${CCACHE_PROGRAM} for speeding up build") set(_compiler_launcher ${SCCACHE_PROGRAM})
elseif (CCACHE_PROGRAM)
set(_compiler_launcher ${CCACHE_PROGRAM})
endif () 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) include(${CMAKE_CURRENT_LIST_DIR}/cmake/GIT.cmake)
find_package(Qt${MAJOR_QT_VERSION} REQUIRED find_package(Qt${MAJOR_QT_VERSION} REQUIRED