What does the syntax CONFIG(debug,debug|release) mean ? What does the 1st argument specify and similarly what is the 2nd ?

When qmake [doc.qt.nokia.com] processes a pro file it could process it up to three times depending on what the configuration is set to. Usually it will do it three times. Once for debug, once for release and one final one for debug_and_release. This is so that both configurations can be generated for at the same time. Therefore when it is required to have debug/release specific settings in a pro file then there is a need to check if qmake is processing the pro file with a particular configuration in mind. As “debug” and “release” might be in CONFIG at the same time a check for just debug or release is likely to always be true (particularly if you have debug_and_release enabled). So, this construct

  1. CONFIG(debug, debug|release) {
  2.     HEADERS += debug.h
  3.     SOURCES += debug.c
  4. }

checks for when the debug configuration is being processed comparing where “debug” and “release” are mutually exclusive. As CONFIGs are order dependent (ie the last one set will be considered the active config for mutual exclusive sets like debug and release) a second parameter can be used to specify a set of values to consider, for example:

  1.         CONFIG = debug
  2.         CONFIG += release
  3.         CONFIG(release, debug|release):message(Release build!)#will be displayed
  4.         CONFIG(debug, debug|release):message(Debug build!) #not displayed

Note that you should use the build_pass [doc.qt.nokia.com] variable to filter out messages, otherwise you will get messages when it creates the Makefile which will be the configuration specific makefile. When adding the build_pass variable in conjunction with the following scope

  1. build_pass:CONFIG(debug, debug|release) {
  2. message(Debug bulid)
  3. }
  4. else:build_pass {
  5. message(Release build)
  6. }

the output will be as follows:

Project MESSAGE: Debug build
Project MESSAGE: Release build

1 comment

August 29, 2012

Picture of landrew landrew

Lab Rat

Typo: “(Debug bulid)”

Write a comment

Sorry, you must be logged in to post a comment.