Important: Please read the Qt Code of Conduct -

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

  • Hello.

    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?

  • Thank you. I have examined the article carefully. The code:
    @CONFIG { message(Debug build) } else { message(Release build) }@
    simply don't work with error "Unexpected else".

    The next code sample,
    @build_pass:CONFIG {
    message(Debug build)
    else:build_pass {
    message(Release build)
    Don't raise an error, but no message will be displayed since qmake don't have "build_pass" variable/condition defined :(.
    So, maybe you can clarify what exactly i need to write in my .pro file so message() will output "debug" at debug build and "release" at release build?

  • Oh, wow. There's actually a parsing bug there. What I typed is correct, but if you omit the code markup, it becomes a tooltip for CONFIG (try hovering the mouse on it)...

  • Ah, i got it. It's
    @CONFIG(debug,debug|release) {
    message( debug )
    } else {
    message( release )

    Thanks again :)

  • sEmpty(QT_BUILD_PARTS) { #defaults symbian
    QT_BUILD_PARTS = libs tools examples demos
    } else {
    QT_BUILD_PARTS = libs tools examples demos docs translations
    } else { #make sure the order makes sense
    contains(QT_BUILD_PARTS, translations) {
    QT_BUILD_PARTS -= translations
    QT_BUILD_PARTS = translations $$QT_BUILD_PARTS
    contains(QT_BUILD_PARTS, tools) {
    QT_BUILD_PARTS -= tools
    unexpected else error hw to remove it

Log in to reply