Debug/Release-only configuration in qmake



  • I need to copy some shared libraries to my output. I want debug versions of these libraries to be copied when building debug, release versions to be copied when building release. Here's part of my QML file:

    # Build Artifacts 
    DESTDIR=$$TOP_BUILDDIR/$$MODULE
    cpqmldir.files = qmldir
    CONFIG(debug) {
      cpqmldir.files += \
        $${3RDPARTY_PATH}/foo/lib/bard.so \
        $${3RDPARTY_PATH}/foo/lib/jamd.so
      message("OMG DEBUG")
    }
    CONFIG(release) {
      cpqmldir.files += \
        $${3RDPARTY_PATH}/foo/lib/bar.so \
        $${3RDPARTY_PATH}/foo/lib/jam.so
      message("OMG RELEASE")
    }
    cpqmldir.path = $$TOP_BUILDDIR/$$MODULE
    COPIES += cpqmldir
    

    However, whether I build in debug or release, I always see both "OMG DEBUG" and "OMG RELEASE", and both sets of libraries get copied.

    Why are both blocks being run? I must be confused by how CONFIG() is intended to be used.

    How do I prevent debug libraries from being copied in a release build?

    Linux 14.04x64, QMake v3.1 using Qt v5.9.3


  • Qt Champions 2017

    Hi @Phrogz,

    The correct way to use the config scopes is like following:

    CONFIG(debug, debug|release) {
       # do debug things here
    }
    CONFIG(release, debug|release) {
       # do release things here
    }
    

    For more info see http://doc.qt.io/qt-5/qmake-variable-reference.html



  • @aha_1980 Thanks! I thought that debug|release was a bitwise or, saying "do this in debug or release modes". I don't understand the syntax at all, but blindly copying the syntax as you wrote works.

    More information on the syntax can be found here:
    What does the syntax CONFIG(debug,debug|release) mean? What does the 1st argument specify and similarly what is the 2nd?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.