Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

qt

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?

like image 603
grigoryvp Avatar asked Feb 27 '11 16:02

grigoryvp


2 Answers

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.

like image 110
Sergei Tachenov Avatar answered Nov 03 '22 22:11

Sergei Tachenov


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.

like image 45
hashDefine Avatar answered Nov 03 '22 22:11

hashDefine