2

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.

Community
  • 1
  • 1
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • 3
    CONFIG(debug, debug|release):win32:LIBS ~= s/-l(.*)/-l\1d/g – Devopia Apr 06 '16 at 02:59
  • Would you mind to explain what the `win32:debug:LIBS ~= s/-l(.*)/-l\1d/g` does? – KcFnMi Apr 06 '16 at 12:42
  • Possible duplicate of [How to detect Qt Creator's target (debug/release) (Visual Studio)](http://stackoverflow.com/questions/32046181/how-to-detect-qt-creators-target-debug-release-visual-studio) – adlag Apr 08 '16 at 06:49

2 Answers2

2

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:

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
0

Thats how I do it normally:

 CONFIG(debug, debug|release) {
    unix:  TARGET = $$join(TARGET,,,d)
    win32: TARGET = $$join(TARGET,,,d)
 }

platform is present because initially I thought to use different conventions for different platforms and giving here just as an example

you can add this rule right after you set a target name for libs/apps

normal layout have this rule in the .pro file for generation your library and something like:

CONFIG(debug, debug|release) {
    unix:   LIBS += -L../libs -L../../libs -lyourlibnamed
    win32: LIBS += -L../libs -L../../libs -lyourlibnamed    
} else {
    unix:   LIBS += -L../libs -L../../libs -lyourlibname
    win32: LIBS += -L../libs -L../../libs -lyourlibname 
}

in a .pri file

evilruff
  • 3,947
  • 1
  • 15
  • 27