diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ac21fb4..4094a5a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.gitignore b/.gitignore index 9e585923..620f233a 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,6 @@ resources/resources_autogenerated.qrc # Leftovers from running `aqt install` aqtinstall.log + +# sccache (CI) +.sccache diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ffa81b2..f8d8cf42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0714104e..d433a0ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,11 +42,30 @@ 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) find_package(Qt${MAJOR_QT_VERSION} REQUIRED