diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-09-12 10:27:16 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-09-18 08:24:38 +0200 |
commit | 1456b8091a681316f0e6256554fd138c6399f564 (patch) | |
tree | 240b0abad07e80f1aea92a36fd31727dba99e32a | |
parent | 983cfc773d1f24badbdeafd6fbbb2a5940c6f614 (diff) |
Make it possible to undefine NDEBUG for nmake and VS projects
For nmake and VS projects we added the NDEBUG define for the release
configuration unconditionally within the qmake generators. To undefine
it, users had to use a nasty work-around.
Now, define NDEBUG within the MSVC mkspecs. In order to do that we
introduce the DEFINES_RELEASE and DEFINES_DEBUG variables that are
merged into DEFINES in default_pre.prf.
Users can unset NDEBUG by writing
DEFINES -= NDEBUG
in their .pro file.
Note that DEFINES_RELEASE and DEFINES_DEBUG are merged in
default_pre.prf in order to give extra compilers (like moc) the chance
to see the fully resolved DEFINES variable. This is different from the
QMAKE_CFLAGS_(DEBUG|RELEASE) variables that get merged in default_post.prf.
Fixes: QTBUG-78071
Change-Id: I381770a1d2f974fbae9b09a2254e3f2fc7842b68
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r-- | mkspecs/common/msvc-desktop.conf | 1 | ||||
-rw-r--r-- | mkspecs/common/winrt_winphone/qmake.conf | 1 | ||||
-rw-r--r-- | mkspecs/features/default_pre.prf | 6 | ||||
-rw-r--r-- | qmake/doc/src/qmake-manual.qdoc | 20 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_nmake.cpp | 4 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_objectmodel.cpp | 1 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 3 |
7 files changed, 28 insertions, 8 deletions
diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf index 0b94e5a3f5..034fd3b305 100644 --- a/mkspecs/common/msvc-desktop.conf +++ b/mkspecs/common/msvc-desktop.conf @@ -19,6 +19,7 @@ CONFIG += flat debug_and_release debug_and_release_target precom # MSVC 2017 15.8+ fixed std::aligned_storage but compilation fails without # _ENABLE_EXTENDED_ALIGNED_STORAGE flag since the fix breaks binary compatibility. DEFINES += UNICODE _UNICODE WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE +DEFINES_RELEASE += NDEBUG QMAKE_COMPILER_DEFINES += _WIN32 contains(QMAKE_TARGET.arch, x86_64) { DEFINES += WIN64 diff --git a/mkspecs/common/winrt_winphone/qmake.conf b/mkspecs/common/winrt_winphone/qmake.conf index 03fb96f2c5..e683018a81 100644 --- a/mkspecs/common/winrt_winphone/qmake.conf +++ b/mkspecs/common/winrt_winphone/qmake.conf @@ -11,6 +11,7 @@ CONFIG = package_manifest $$CONFIG incremental flat precompile_ # MSVC 2017 15.8+ fixed std::aligned_storage but compilation fails without # _ENABLE_EXTENDED_ALIGNED_STORAGE flag since the fix breaks binary compatibility. DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT Q_BYTE_ORDER=Q_LITTLE_ENDIAN _ENABLE_EXTENDED_ALIGNED_STORAGE +DEFINES_RELEASE += NDEBUG QMAKE_COMPILER_DEFINES += _WIN32 DEPLOYMENT_PLUGIN += qwinrt diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf index 1c24bf071a..b2629d04c0 100644 --- a/mkspecs/features/default_pre.prf +++ b/mkspecs/features/default_pre.prf @@ -26,4 +26,10 @@ CONFIG = \ unset(today) } +CONFIG(debug, debug|release) { + DEFINES += $$DEFINES_DEBUG +} else { + DEFINES += $$DEFINES_RELEASE +} + load(toolchain) diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 3495f97b2c..a388b89477 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1144,6 +1144,26 @@ \snippet code/doc_src_qmake-manual.pro 27 + \target DEFINES_DEBUG + \section1 DEFINES_DEBUG + + Specifies preprocessor defines for the debug configuration. The values of + this variable get added to \l{DEFINES} before the project is loaded. This + variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs + to be modified. + + This variable was introduced in Qt 5.13.2. + + \target DEFINES_RELEASE + \section1 DEFINES_RELEASE + + Specifies preprocessor defines for the release configuration. The values of + this variable get added to \l{DEFINES} before the project is loaded. This + variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs + to be modified. + + This variable was introduced in Qt 5.13.2. + \target DEF_FILE \section1 DEF_FILE diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 63d89a5388..fd90cfcb2a 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -281,10 +281,6 @@ void NmakeMakefileGenerator::init() if (project->isActiveConfig("debug")) { project->values("QMAKE_CLEAN").append(targetBase + ".ilk"); project->values("QMAKE_CLEAN").append(targetBase + ".idb"); - } else { - ProStringList &defines = project->values("DEFINES"); - if (!defines.contains("NDEBUG")) - defines.append("NDEBUG"); } if (project->values("QMAKE_APP_FLAG").isEmpty() && project->isActiveConfig("dll")) { diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 506229a7f4..5fb6bfb320 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2125,7 +2125,6 @@ VCResourceCompilerTool::VCResourceCompilerTool() ShowProgress(linkProgressNotSet), SuppressStartupBanner(unset) { - PreprocessorDefinitions = QStringList("NDEBUG"); } // VCDeploymentTool -------------------------------------------- diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index b6f7f20564..df4876ace7 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1038,9 +1038,6 @@ void VcprojGenerator::initConfiguration() initDeploymentTool(); initWinDeployQtTool(); initPreLinkEventTools(); - - if (!isDebug) - conf.compiler.PreprocessorDefinitions += "NDEBUG"; } void VcprojGenerator::initCompilerTool() |