11# SPDX-FileCopyrightText: 2021 Tenacity Audio Editor contributors
22# SPDX-FileContributor: Be <be.0@gmx.com>
33# SPDX-FileContributor: Emily Mabrey <emabrey@tenacityaudio.org>
4+ # SPDX-FileContributor: Leon Matthes <leon.matthes@kdab.com>
45#
56# SPDX-License-Identifier: BSD-3-Clause
67#[=======================================================================[.rst:
78CompilerCaching
89---------------
910
1011Search for sccache and ccache and use them for compiler caching for C & C++.
11- ccache is preferred if both are found, but the user can override this by
12- explicitly setting CCACHE =OFF to use sccache when both are installed.
12+ sccache is preferred if both are found, but the user can override this by
13+ explicitly setting SCCACHE =OFF to use ccache when both are installed.
1314#]=======================================================================]
1415
1516# ccache does not support MSVC
@@ -33,14 +34,12 @@ else()
3334 option (SCCACHE "Use sccache for compiler caching to speed up rebuilds." ON )
3435endif ()
3536
36- if (CCACHE)
37- message (STATUS "Using ccache for compiler caching to speed up rebuilds" )
38- set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
39- set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
40- elseif (SCCACHE)
37+ if (SCCACHE)
4138 message (STATUS "Using sccache for compiler caching to speed up rebuilds" )
4239 set (CMAKE_C_COMPILER_LAUNCHER "${SCCACHE_PROGRAM} " )
4340 set (CMAKE_CXX_COMPILER_LAUNCHER "${SCCACHE_PROGRAM} " )
41+ # Enable sccache for rustc - especially important when building cxx-qt-lib!
42+ set (CMAKE_RUSTC_WRAPPER "${SCCACHE_PROGRAM} " CACHE PATH "RUSTC_WRAPPER detected by CMake" )
4443
4544 # Instruct MSVC to generate symbolic debug information within object files for sccache
4645 if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
@@ -56,6 +55,10 @@ elseif(SCCACHE)
5655 string (REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_${CONFIG} "${CMAKE_C_FLAGS_${CONFIG} }" )
5756 endif ()
5857 endif ()
58+ elseif (CCACHE)
59+ message (STATUS "Using ccache for compiler caching to speed up rebuilds" )
60+ set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
61+ set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
5962else ()
6063 if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
6164 message (STATUS "No compiler caching enabled. Install sccache to speed up rebuilds." )
0 commit comments