grigoryvp
grigoryvp

Reputation: 42483

How to set different qmake configuration depending on debug / release?

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?

Upvotes: 19

Views: 10709

Answers (2)

hashDefine
hashDefine

Reputation: 1491

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.

Upvotes: 8

Sergei Tachenov
Sergei Tachenov

Reputation: 24869

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.

Upvotes: 24

Related Questions