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.

Pick-to: 6.2 5.15
Task-number: QTBUG-89296
Change-Id: I885061802c1350b293a7868d4c9a9367d30e2380
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2021-08-25 11:52:59 +02:00
parent 5e98769602
commit a6a216e310

View File

@ -37,6 +37,7 @@
#include <qcryptographichash.h>
#include <qhash.h>
#include <quuid.h>
#include <qregularexpression.h>
#include <stdlib.h>
@ -1034,6 +1035,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 QRegularExpression rex("^[/-]std:");
for (const ProString &flag : flags) {
if (rex.match(flag.toQString()).hasMatch()) {
result.append(flag);
}
}
return result;
}
void VcprojGenerator::initCompilerTool()
{
QString placement = project->first("OBJECTS_DIR").toQString();
@ -1056,6 +1071,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"))