Linux – Qt Creator CONFIG (debug, release) switches does NOT work

linuxqtqt-creatorwindows

Problem: CONFIG(debug,debug|release) and CONFIG(release,deubg|release) are always evaluated wherever debug or release is choosen in Qt Creator 2.8.1 for Linux.

My configuration in Qt Creator application (stock – default for new project):

Projects->Build Settings->Debug Build Steps:
  qmake build configuration: Debug
  Effective qmake call: qmake2 proj.pro -r -spec linux-gnueabi-oe-g++ CONFIG+=debug

Projects->Build Settings->Release Build Steps:
  qmake build configuration: Release
  Effective qmake call: qmake2 proj.pro -r -spec linux-gnueabi-oe-g++

My configuration in proj.pro:

message(Variable CONFIG:)
message($$CONFIG)
CONFIG(debug,debug|release)
{
    message(Debug build)
}
CONFIG(release,debug|release)
{
    message(Release build)
}

Output on console for Debug:

Project MESSAGE: Variable CONFIG:
Project MESSAGE: lex yacc warn_on debug uic resources warn_on release incremental link_prl no_mocdepend release stl qt_no_framework debug console
Project MESSAGE: Debug build
Project MESSAGE: Release build

Output on console for Release:

Project MESSAGE: Variable CONFIG:
Project MESSAGE: lex yacc warn_on uic resources warn_on release incremental link_prl no_mocdepend release stl qt_no_framework console
Project MESSAGE: Debug build
Project MESSAGE: Release build

Under Windows 7 I didnt experienced any problem with such .pro configuration and it worked fine.
I was desperate and modified .pro file:

CONFIG = test
message(Variable CONFIG:)
message($$CONFIG)
CONFIG(debug,debug|release)
{
    message(Debug build)
}
CONFIG(release,debug|release)
{
    message(Release build)
}

and I was suprised with the output:

Project MESSAGE: Variable CONFIG:
Project MESSAGE: test
Project MESSAGE: Debug build
Project MESSAGE: Release build

so even if I completly clean CONFIG variable it still see debug and release configuration.

What Im doing wrong?

Best Answer

Qmake is insane, that is the only viable explanation. The whole release/debug being in config multiple times smells like an old design bug that was never resolved before it was to late and too many configurations were already written. Remember tabs in make? Dude had like 15 users, so he never fixed the bad decisions.

Anyway.

I see the same issue on linux, on Qt 4.8.4.1.

And here is the solution: remove the line break before curly bracket.

Literally, this works:

CONFIG(release, debug|release) {
    message(Release)
}

CONFIG(debug, debug|release) {
    message(Debug)
} 

While this does not:

CONFIG(release, debug|release) 
{
    message(Release)
}

CONFIG(debug, debug|release) 
{
    message(Debug)
} 

I suspect this is a parsing bug in a few versions of qmake, possibly on linux side only.

Related Topic