Skip to content

Commit

Permalink
Add qmake feature and configure option to use ccache
Browse files Browse the repository at this point in the history
Enabled via configure --ccache, or CONFIG += ccache in 3rd party
projects.

Ensures that we use the right sloppiness and other ccache options
during compilation.

Task-number: QTBUG-31034
Change-Id: I696b3d3f0398873a29b93d1bc2b4d4e06ef23dc9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
  • Loading branch information
torarnv committed Sep 5, 2017
1 parent 0adc14d commit d649408
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions config_help.txt
Expand Up @@ -144,6 +144,7 @@ Build options:
-ltcg ................ Use Link Time Code Generation [no]
-use-gold-linker ..... Use the GNU gold linker [auto]
-incredibuild-xge .... Use the IncrediBuild XGE [no] (Windows only)
-ccache .............. Use the ccache compiler cache [no] (Unix only)
-make-tool <tool> .... Use <tool> to build qmake [nmake] (Windows only)
-mp .................. Use multiple processors for compilation (MSVC only)

Expand Down
17 changes: 17 additions & 0 deletions configure.json
Expand Up @@ -61,6 +61,7 @@
"avx2": "boolean",
"avx512": { "type": "boolean", "name": "avx512f" },
"c++std": "cxxstd",
"ccache": { "type": "boolean", "name": "ccache" },
"commercial": "void",
"compile-examples": { "type": "boolean", "name": "compile_examples" },
"confirm-license": "void",
Expand Down Expand Up @@ -620,6 +621,11 @@
"label": "IncrediBuild",
"type": "files",
"files": [ "BuildConsole.exe", "xgConsole.exe" ]
},
"ccache": {
"label": "ccache",
"type": "files",
"files": [ "ccache" ]
}
},

Expand Down Expand Up @@ -1206,6 +1212,12 @@
"condition": "tests.incredibuild_xge",
"output": [ "publicConfig" ]
},
"ccache": {
"label": "Using ccache",
"autoDetect": false,
"condition": "config.unix && tests.ccache",
"output": [ "privateConfig" ]
},
"msvc_mp": {
"label": "Use multiple processors when compiling with MSVC",
"emitIf": "config.msvc",
Expand Down Expand Up @@ -1313,6 +1325,11 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
"type": "firstAvailableFeature",
"args": "c++1z c++14 c++11"
},
{
"type": "feature",
"args": "ccache",
"condition": "config.unix"
},
"use_gold_linker",
{
"type": "feature",
Expand Down
19 changes: 19 additions & 0 deletions mkspecs/features/unix/ccache.prf
@@ -0,0 +1,19 @@
macx-xcode: return()

darwin: load(sdk)

ccache_prefix = ccache

precompile_header {
CCACHE_SLOPPINESS += pch_defines time_macros

ccache_prefix = \
CCACHE_SLOPPINESS=\"$$join(CCACHE_SLOPPINESS, ',')\$${CCACHE_SLOPPINESS+,\$$CCACHE_SLOPPINESS}\" \
# Make sure we build sources directly, not from their preprocessed version,
# otherwise precompiled headers will not be used during cache misses.
CCACHE_CPP2=true \
$$ccache_prefix
}

for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_LINK_C)): \
$$tool = $$ccache_prefix $$eval($$tool)

0 comments on commit d649408

Please sign in to comment.