forked from qt-creator/qt-creator
ProjectExplorer: Consider the form "-D key=value"
... when filtering compiler options for MSVC macro extractions. Otherwise we end up with a stray command line argument, breaking the call to cl.exe. Fixes: QTCREATORBUG-28016 Change-Id: I29979a4b968d2056a0feba61fee01d5ddc9aa28f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -621,15 +621,22 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
Macros predefinedMacros;
|
||||
|
||||
QStringList toProcess;
|
||||
for (const QString &arg : cxxflags) {
|
||||
if (arg.startsWith("/D") || arg.startsWith("-D")) {
|
||||
const QString define = arg.mid(2);
|
||||
predefinedMacros.append(Macro::fromKeyValue(define));
|
||||
} else if (arg.startsWith("/U") || arg.startsWith("-U")) {
|
||||
predefinedMacros.append(
|
||||
{arg.mid(2).toLocal8Bit(), ProjectExplorer::MacroType::Undefine});
|
||||
for (auto arg = cxxflags.begin(); arg != cxxflags.end(); ++arg) {
|
||||
if (arg->startsWith("/D") || arg->startsWith("-D")) {
|
||||
if (arg->length() > 2)
|
||||
predefinedMacros.append(Macro::fromKeyValue(arg->mid(2)));
|
||||
else if (std::next(arg) != cxxflags.end())
|
||||
predefinedMacros.append(Macro::fromKeyValue(*++arg));
|
||||
} else if (arg->startsWith("/U") || arg->startsWith("-U")) {
|
||||
if (arg->length() > 2) {
|
||||
predefinedMacros.append({arg->mid(2).toLocal8Bit(),
|
||||
MacroType::Undefine});
|
||||
} else if (std::next(arg) != cxxflags.end()) {
|
||||
predefinedMacros.append({(++arg)->toLocal8Bit(),
|
||||
MacroType::Undefine});
|
||||
}
|
||||
} else {
|
||||
toProcess.append(arg);
|
||||
toProcess.append(*arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user