Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Debug/Release-only configuration in qmake

    Tools
    2
    3
    4150
    Loading More Posts
    • 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.
    • Phrogz
      Phrogz last edited by 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_1980 1 Reply Last reply Reply Quote 0
      • aha_1980
        aha_1980 Lifetime Qt Champion @Phrogz last edited by

        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.

        Phrogz 1 Reply Last reply Reply Quote 3
        • Phrogz
          Phrogz @aha_1980 last edited by Phrogz

          @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 Reply Quote 1
          • First post
            Last post