CONFIG += debug_and_release



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



  • 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.



  • 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



  • 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.



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



  • 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.


Log in to reply
 

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