2

I want to change some DEFINES and LIBS paths depending on Debug or Release build configuration, but my CONFIG variable constains release and debug variables at the same time.

Simple test in pro file:

CONFIG(debug, debug|release) {
    message(DEBUG build)
}

CONFIG(release, debug|release) {
    message(RELEASE build)
}

This test outputs:

Project MESSAGE: DEBUG build
Project MESSAGE: RELEASE build

How should I set up my project?

László Papp
  • 51,870
  • 39
  • 111
  • 135
Dcow
  • 1,413
  • 1
  • 19
  • 42
  • 1
    It's the last occurrence of "debug" or "release" that counts. See this answer for details: http://stackoverflow.com/a/16974223/856199 – Nikos C. Sep 27 '13 at 18:35

1 Answers1

1

You should use this:

debug_and_release_target {
    CONFIG(debug, debug|release) {
        message("debug")
    } else {
        message("release")
    }   
}

This is what we use inside Qt as well, including QtSerialPort. Although we use this as well for Mac, just in case:

if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
    LIBS += -lQtSerialPort$${QT_LIBINFIX}_debug
} else {
   LIBS += -lQtSerialPort$${QT_LIBINFIX}
}   
László Papp
  • 51,870
  • 39
  • 111
  • 135