Search code examples
c++qtc++11qt4qt5

qmake run command only in debug mode, how?


This is kind of a continuation of this question. I want to run

win32:LIBS ~= s/-l(.*)/-l\1d/g

only for debug builds, since the idea is to appen d to lib names in debug mode.

I tried

win32:debug:LIBS ~= s/-l(.*)/-l\1d/g

But so it also executes in release mode.


Solution

  • You need to use CONFIG(debug, debug|release) instead of a simple test for presence of debug. The CONFIG variable is special, in that it can have multiple debug and release entries in it, but only the last one counts.

    So, even in release mode, your CONFIG might look like something, debug, something, release: the release "wins" since it's the last, but the scope test doesn't know that.

    It's a quirk of qmake. It is even documented, if you know where to look first :/

    As the order of values is important in CONFIG variables (that is, the last one set will be considered the active config for mutually exclusive values) a second parameter can be used to specify a set of values to consider. For example: