Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Debug/Release-only configuration in qmake
QtWS25 Last Chance

Debug/Release-only configuration in qmake

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
3 Posts 2 Posters 4.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PhrogzP Offline
    PhrogzP Offline
    Phrogz
    wrote on last edited by Phrogz
    #1

    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

    aha_1980A 1 Reply Last reply
    0
    • PhrogzP Phrogz

      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

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Qt has to stay free or it will die.

      PhrogzP 1 Reply Last reply
      3
      • aha_1980A aha_1980

        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

        PhrogzP Offline
        PhrogzP Offline
        Phrogz
        wrote on last edited by Phrogz
        #3

        @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?

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved