Important: Please read the Qt Code of Conduct -

QMake 'debug' bug

  • I have not been able to build release code with Qt 5.5, and now I think I know why:
    QMake is not handling 'debug' in CONFIG properly. For example with this code in the .pro file:
    CONFIG(debug){ DEFINES += foobar }
    I get -Dfoobar in makefiles generated for both debug and release builds, regardless of whether the QMake command line contains "CONFIG+=debug".

    I have many library selections that are supposed to be conditional on CONFIG(debug); but only the debug selections are actually getting into the makefiles.

    It is not as if QMake is totally ignoring "CONFIG+=debug", because some elements of the makefile change when it is present, for example this:
    qmake: FORCE
    @$(QMAKE) -spec win32-msvc2013 "CONFIG+=debug" -o Makefile.Release ..\match_wrangler\
    which is absurd but might be evidence of something.

    HELP! I need a workaround, and fast.

  • Moderators

    @tommy said:

    CONFIG(debug){ DEFINES += foobar }

    This should be CONFIG(debug, debug|release){ DEFINES += foobar } for debug-only stuff and CONFIG(release, debug|release){ DEFINES += foobar } for release-only stuff.

  • Thanks, Chris

    That seems to give correct makefiles.

    Would you mind explaining the syntax (the qmake manual doesn't)?

  • @tommy said:

    Would you mind explaining that syntax (the qmake manual doesn't)?

    The documentation (albeit terse) is at


  • Moderators

    Would you mind explaining the syntax (the qmake manual doesn't)?

    I consider it one of the oddities of qmake. The way I understand it CONFIG() function with one parameter just checks if given argument is present in the CONFIG variable, so if you have something like CONFIG += release debug both CONFIG(release) and CONFIG debug will match, so this is not enough.
    The active configuration is determined by the last occurrence of the parameter debug or release in the CONFIG variable, so CONFIG = debug release would be a release build while CONFIG = debug release debugwould be a debug build.
    The second parameter is used to find the last occurrence of it. The syntax debug|release means to look for the last instance of either word debug or release. Then the first parameter of CONFIG is matched against that, not the whole CONFIG variable.

    So for example if CONFIG = debug release (a release build) a second param of function CONFIG(debug, debug|release) would give you release and then the first parameter is matched against that, so the result is false.

Log in to reply