First of all, in qmake debug
and release
tell how Qt itself was built.
For example:
debug {
# If Qt has binary built for debugging.
}
CONFIG(debug) {
# Same as above.
}
release {
# If Qt has binary built for release.
}
CONFIG(release) {
# Same as above.
}
Knowing above, then how is a qmake-script supposed to know whether debug or release is being built?
Well, IDEs like "Qt Creator" do pass an option to qmake.exe
, depending on build-mode, for example:
- "CONFIG+=declarative_debug"
- "CONFIG+=debug"
- "CONFIG+=release"
Finally:
CONFIG(debug, debug|release) {
# If "debug" is added lastly to "CONFIG",
# after all "debug or release" occurences,
# which means, IDE asked for debug build.
}
CONFIG(debug, release|debug) {
# Same as above.
}
CONFIG(release, debug|release) {
# If "release" is added lastly to "CONFIG",
# after all "debug or release" occurences,
# which means, IDE asked for release build.
}
CONFIG(release, release|debug) {
# Same as above.
}
Of course, CONFIG(release, debug|release) {}
is not required, because qmake
supports else
keyword.
What's debug_and_release
?
So far so good, but there is also the CONFIG+=debug_and_release
option, which for Windows may be even by default enabled.
The debug_and_release
has almost nothing to do with qmake's "debug" and "release" build-modes,
and just asks qmake.exe
to generate the "Makefile
" file in a way that supports building both build-modes.
In details:
debug_and_release
causes qmake to parse script 3 times:
- Once without changing what IDE is asking.
- Once with ensuring
release
is last in CONFIG
variable.
- Once with ensuring
debug
is last in CONFIG
variable.
And that in above order (at least, if tested with qmake version 3.0).
Which normally results in qmake generating 3 files:
Makefile
Makefile.release
Makefile.debug
Where the "Makefile
" file takes around 10 times less space,
and does nothing but redirecting "make.exe" to "Makefile.release
" file or "Makefile.debug
" file.
However, if your script logs a single warning, qmake spams 2 additional warnings, which can be work-arounded, like:
!build_pass: warning("My message shown in IDE")
Or:
!build_pass {
warning("My message shown in IDE")
}
Or:
if (!build_pass) {
warning("My message shown in IDE")
}