18

I need to specify different output and intermediate folders in my .pro file for debug and release builds. I created a following test .pro file:

release {
  message( "release" )
}
debug {
  message( "debug" )
}

But compiling this .pro file in Qt Creator with “debug” build leads to following output:

Project MESSAGE: release
Project MESSAGE: debug

It seems that both “debug” and “release” conditions are set to True O_O. Is it possible to somehow handle debug and release builds separately in qmake?

grigoryvp
  • 40,413
  • 64
  • 174
  • 277
  • Possible duplicate of [QMake CONFIG() function and 'active configuration'](https://stackoverflow.com/questions/18164490/qmake-config-function-and-active-configuration) – m7913d Sep 17 '19 at 18:29

2 Answers2

23

According to the qmake manual:

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

I don't really get the explanation, though. It seems that both of the options are really selected, and only one of them is "active". But qmake is famous for counter-intuitive things.

alexisdm
  • 29,448
  • 6
  • 64
  • 99
Sergei Tachenov
  • 24,345
  • 8
  • 57
  • 73
  • 7
    See [this](http://stackoverflow.com/q/18164490/26449) question and its answer for explanation. – Bill Sep 02 '13 at 11:42
8

Try:

CONFIG(debug, debug|release){
message("debug")
} else {
message("release")
}

the qmake will display "debug" if you are building your project in a debug or debug|release mode, otherwise (i.e.: if you are building it in a release mode) a "release" message will be shown.

hashDefine
  • 1,491
  • 6
  • 23
  • 33