QMake 'debug' bug
-
I have not been able to build release code with Qt 5.5, and now I think I know why:
QMake is not handling 'debug' in CONFIG properly. For example with this code in the .pro file:
CONFIG(debug){ DEFINES += foobar }
I get -Dfoobar in makefiles generated for both debug and release builds, regardless of whether the QMake command line contains "CONFIG+=debug".I have many library selections that are supposed to be conditional on CONFIG(debug); but only the debug selections are actually getting into the makefiles.
It is not as if QMake is totally ignoring "CONFIG+=debug", because some elements of the makefile change when it is present, for example this:
qmake: FORCE
@$(QMAKE) -spec win32-msvc2013 "CONFIG+=debug" -o Makefile.Release ..\match_wrangler\PT3D.pro
which is absurd but might be evidence of something.HELP! I need a workaround, and fast.
-
@tommy said:
CONFIG(debug){ DEFINES += foobar }
This should be
CONFIG(debug, debug|release){ DEFINES += foobar }
for debug-only stuff andCONFIG(release, debug|release){ DEFINES += foobar }
for release-only stuff. -
@tommy said:
Would you mind explaining that syntax (the qmake manual doesn't)?
The documentation (albeit terse) is at http://doc.qt.io/qt-5/qmake-test-function-reference.html#config-config
Cheers.
-
Would you mind explaining the syntax (the qmake manual doesn't)?
I consider it one of the oddities of qmake. The way I understand it CONFIG() function with one parameter just checks if given argument is present in the CONFIG variable, so if you have something like
CONFIG += release debug
bothCONFIG(release)
andCONFIG debug
will match, so this is not enough.
The active configuration is determined by the last occurrence of the parameterdebug
orrelease
in the CONFIG variable, soCONFIG = debug release
would be a release build whileCONFIG = debug release debug
would be a debug build.
The second parameter is used to find the last occurrence of it. The syntaxdebug|release
means to look for the last instance of either worddebug
orrelease
. Then the first parameter of CONFIG is matched against that, not the whole CONFIG variable.So for example if
CONFIG = debug release
(a release build) a second param of functionCONFIG(debug, debug|release)
would give yourelease
and then the first parameter is matched against that, so the result isfalse
.