qmake: Make ccache feature available on windows hosts

Previously the ccache feature was only available on Unix-like
hosts. This change makes it available on Windows hosts as well.

Guard the ccache sloppiness assignments not to run on Windows hosts,
due to syntax errors in the Windows shell.

Also make sure to only wrap the compilers when targeting msvc,
otherwise sccache specifically will complain when executing link.exe,
which is a linker. ccache doesn't have this issue.

Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-139139
Change-Id: Icf314cf53197d6372c2794ecfb52786c1f9ee6d4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2025-08-14 15:38:56 +02:00
parent 21d561106f
commit 46a939a700
1 changed files with 10 additions and 2 deletions

View File

@ -8,7 +8,7 @@ launcher_prefix = ccache
launcher_prefix = $$QMAKE_CACHE_LAUNCHER_PREFIX launcher_prefix = $$QMAKE_CACHE_LAUNCHER_PREFIX
} }
precompile_header:contains(launcher_prefix, ccache) { precompile_header:contains(launcher_prefix, ccache):!equals(QMAKE_HOST.os, Windows) {
CCACHE_SLOPPINESS += pch_defines time_macros CCACHE_SLOPPINESS += pch_defines time_macros
launcher_prefix = \ launcher_prefix = \
@ -19,5 +19,13 @@ precompile_header:contains(launcher_prefix, ccache) {
$$launcher_prefix $$launcher_prefix
} }
for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_LINK_C)): \ # sccache doesn't recognize that link.exe is a linker, not a compiler, so when targeting msvc
# only wrap the compiler tools.
msvc {
tools = QMAKE_CC QMAKE_CXX
} else {
tools = QMAKE_CC QMAKE_CXX QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_LINK_C
}
for(tool, tools): \
$$tool = $$launcher_prefix $$eval($$tool) $$tool = $$launcher_prefix $$eval($$tool)