November 5, 2010

adi_hodos adi_hodos
Lab Rat
2 posts

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

5 replies

November 5, 2010

ad5xj ad5xj
Lab Rat
61 posts

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.

 Signature 

Ken AD5XJ

November 5, 2010

adi_hodos adi_hodos
Lab Rat
2 posts

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

November 5, 2010

ad5xj ad5xj
Lab Rat
61 posts

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:

  1. win32 {
  2.           build_pass:CONFIG(debug, debug|release) {
  3.             TARGET = qttest_debug
  4.          } else {
  5.             TARGET = qttest_release
  6.          }
  7. }

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


The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified

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.

 Signature 

Ken AD5XJ

November 5, 2010

adi_hodos adi_hodos
Lab Rat
2 posts

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 ?

November 5, 2010

ad5xj ad5xj
Lab Rat
61 posts

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:


win32 { build_pass:CONFIG { 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.

 Signature 

Ken AD5XJ

 
  ‹‹ Running out of memory, how do I set a more memory compiler option?      Qmlviewer no longer comes with Qt Creator ››

You must log in to post a reply. Not a member yet? Register here!