summaryrefslogtreecommitdiffstats
path: root/qmake/generators
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-08-25 11:52:59 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-08-30 14:14:39 +0200
commitede7f85c07551c3b429a7e71a2cee47d32a553fb (patch)
tree9366f8b7057de38c5c09533935da679e89fc810d /qmake/generators
parent46a16164107e375d78f9aaa3c0ab6e9fcb375f95 (diff)
qmake/vcxproj: Read C language standard from QMAKE_CFLAGS
The vcxproj generator completely ignored QMAKE_CFLAGS and did only read QMAKE_CXXFLAGS. The msbuild-internal "cl compiler tool" contains the flags for both, C and C++. It is to risky to take all QMAKE_CFLAGS into account for the "cl compiler tool", because this might collide with what is specified in QMAKE_CXXFLAGS. Therefore, we only read the /std:... compiler option from QMAKE_CFLAGS and set the LanguageStandard_C flag in the msbuild file. Task-number: QTBUG-89296 Change-Id: I885061802c1350b293a7868d4c9a9367d30e2380 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit a6a216e31041f6c878a37d9af169f221d99978c8)
Diffstat (limited to 'qmake/generators')
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index a1f8fe7b87..14588e1538 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -37,6 +37,7 @@
#include <qcryptographichash.h>
#include <qhash.h>
#include <quuid.h>
+#include <qregexp.h>
#include <stdlib.h>
@@ -1052,6 +1053,20 @@ void VcprojGenerator::initConfiguration()
initPreLinkEventTools();
}
+// Filter from the given QMAKE_CFLAGS the options that are relevant
+// for the vcxproj-global VCCLCompilerTool.
+static ProStringList relevantCFlags(const ProStringList &flags)
+{
+ ProStringList result;
+ static const QRegExp rex("^[/-]std:.*");
+ for (const ProString &flag : flags) {
+ if (rex.exactMatch(flag.toQString())) {
+ result.append(flag);
+ }
+ }
+ return result;
+}
+
void VcprojGenerator::initCompilerTool()
{
QString placement = project->first("OBJECTS_DIR").toQString();
@@ -1074,6 +1089,7 @@ void VcprojGenerator::initCompilerTool()
conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER").toQStringList();
}
+ conf.compiler.parseOptions(relevantCFlags(project->values("QMAKE_CFLAGS")));
conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS"));
if (project->isActiveConfig("windows"))