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. CONFIG += debug_and_release

CONFIG += debug_and_release

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 2 Posters 12.1k 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.
  • A Offline
    A Offline
    adi_hodos
    wrote on last edited by
    #1

    I have a project with the following settings :

    CONFIG = qt thread resources
    CONFIG += debug_and_release
    DEFINES = QT_DLL
    QT += network sql
    TARGET = qttest
    TEMPLATE = app
    SOURCES_DIR = src
    PRECOMPILED_HEADER = $${SOURCES_DIR}/app_pch.h
    SOURCES = $$SOURCES_DIR/qttest.cc

    win32 {
    CONFIG += windows
    DEFINES += OS_WINDOWS

    CONFIG(debug, debug|release) {
    TARGET = $${TARGET}_dbg
    QMAKE_CXX_FLAGS_MT_DBG += /Od /D_DEBUG
    } else {
    TARGET = $${TARGET}_release
    }
    }

    But in the generated Makefile.Debug these settings appear with _release appended to them, instead of _dbg :

    QMAKE_TARGET = qttest_release
    DESTDIR = #avoid trailing-slash linebreak
    TARGET = qttest_release.exe
    DESTDIR_TARGET = qttest_release.exe

    Also none of the flags defined for QMAKE_CXX_FLAGS_MT_DBG appear.

    Also if I put :

    build_pass:CONFIG(debug, debug|release) {
    message("Debug pass")
    } else {
    message("Release pass")
    }

    only "Release pass" gets printed when running qmake. Shouldn't both be printed ?
    Am I doing something wrong here ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ad5xj
      wrote on last edited by
      #2

      Do you want a different message/CONFIG for Win32 and Linux on the buildpass for debug and release?

      If so your build_pass phrase is inadequate.

      Ken AD5XJ

      1 Reply Last reply
      0
      • A Offline
        A Offline
        adi_hodos
        wrote on last edited by
        #3

        No, the problem is that the generated Makefile.Debug contains settings from the release configuration.
        For example, these :
        QMAKE_TARGET = qttest_release
        DESTDIR = #avoid trailing-slash linebreak
        TARGET = qttest_release.exe
        DESTDIR_TARGET = qttest_release.exe

        should be

        QMAKE_TARGET = qttest_dbg
        DESTDIR = #avoid trailing-slash linebreak
        TARGET = qttest_dbg.exe
        DESTDIR_TARGET = qttest_dbg.exe

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ad5xj
          wrote on last edited by
          #4

          I am not convinced that you are correct in your assumption.

          In order for the target to be called a different name in debug and release you must set the TARGET variable differently for each build_pass something like this:

          [code]
          win32 {
          build_pass:CONFIG(debug, debug|release) {
          TARGET = qttest_debug
          } else {
          TARGET = qttest_release
          }
          }
          [/code]

          your $${TARGET}_debug(release) substitution could also work with the above modifications.

          Just be careful not to include spaces in the name unless you use the $$quote() macro. Spaces are a problem on Linux with QtCreator pathnames.

          also. . .

          From the docs on QMAKE_TARGET
          [quote]
          The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified
          [/quote]

          In other words it is better to change the TARGET variable and not QMAKE_TARGET unless there is some overriding factor to do so.

          If paths and target names are different for Linux and Unix you must also have a unix {} phrase to define it.

          Ken AD5XJ

          1 Reply Last reply
          0
          • A Offline
            A Offline
            adi_hodos
            wrote on last edited by
            #5

            I know what the problem was. The DESTDIR and TARGET variables appear both in the debug and release scopes, thus they get overwritten with the settings from whatever configuration is processed last (debug or release).
            But I would like to set different output directories (and maybe different names) for the executables in debug and release, eg :
            debug/app/app_exe_dbg
            release/app/app_exe_rel
            Is there anyway that this can be done ?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ad5xj
              wrote on last edited by
              #6

              I think that is what I was trying to illustrate. If you want to make the DESTDIR and TARGET have different values for debug and release you must define them for each like this:

              [code]
              win32 {
              build_pass:CONFIG(debug, debug|release) {
              DESTDIR = debug/app
              TARGET = qttest_debug
              } else {
              DESTDIR = release/app
              TARGET = qttest_release
              }
              }

              However, it would be cleaner to define the shadow build paths for each rather than include in the .pro.

              Ken AD5XJ

              1 Reply Last reply
              0

              • Login

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