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,14 @@ 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+ if (NOT DEFINED ENV{RUSTC_WRAPPER})
42+ # Enable sccache for rustc - especially important when building cxx-qt-lib!
43+ set (CMAKE_RUSTC_WRAPPER "${SCCACHE_PROGRAM} " CACHE PATH "RUSTC_WRAPPER detected by CMake" )
44+ endif ()
4445
4546 # Instruct MSVC to generate symbolic debug information within object files for sccache
4647 if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
@@ -56,6 +57,10 @@ elseif(SCCACHE)
5657 string (REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_${CONFIG} "${CMAKE_C_FLAGS_${CONFIG} }" )
5758 endif ()
5859 endif ()
60+ elseif (CCACHE)
61+ message (STATUS "Using ccache for compiler caching to speed up rebuilds" )
62+ set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
63+ set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
5964else ()
6065 if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
6166 message (STATUS "No compiler caching enabled. Install sccache to speed up rebuilds." )
0 commit comments