Commit e7a18108 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

CppTools: Fix macro collection.



"#define XYZ" does not correspond to "-DXYZ" (which means
"#define XYZ 1"), but to "-DXYZ=".

Change-Id: I3ed44e1457b3df52dc9bdb930ba8f4a04784d207
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 56637a5d
...@@ -511,7 +511,6 @@ QStringList CompilerOptionsBuilder::createDefineOptions(const QByteArray &define ...@@ -511,7 +511,6 @@ QStringList CompilerOptionsBuilder::createDefineOptions(const QByteArray &define
const QString &toolchainType) const QString &toolchainType)
{ {
QStringList result; QStringList result;
const QString option = QLatin1String(toolchainType == QLatin1String("msvc") ? "/D" : "-D");
foreach (QByteArray def, defines.split('\n')) { foreach (QByteArray def, defines.split('\n')) {
if (def.isEmpty()) if (def.isEmpty())
...@@ -535,12 +534,11 @@ QStringList CompilerOptionsBuilder::createDefineOptions(const QByteArray &define ...@@ -535,12 +534,11 @@ QStringList CompilerOptionsBuilder::createDefineOptions(const QByteArray &define
QByteArray str = def.mid(8); QByteArray str = def.mid(8);
int spaceIdx = str.indexOf(' '); int spaceIdx = str.indexOf(' ');
QString arg; const QString option = QLatin1String(toolchainType == QLatin1String("msvc") ? "/D" : "-D");
if (spaceIdx != -1) { const bool hasValue = spaceIdx != -1;
arg = option + QLatin1String(str.left(spaceIdx) + "=" + str.mid(spaceIdx + 1)); QString arg = option + QLatin1String(str.left(hasValue ? spaceIdx : str.size()) + '=');
} else { if (hasValue)
arg = option + QLatin1String(str); arg += QLatin1String(str.mid(spaceIdx + 1));
}
arg = arg.replace(QLatin1String("\\\""), QLatin1String("\"")); arg = arg.replace(QLatin1String("\\\""), QLatin1String("\""));
arg = arg.replace(QLatin1String("\""), QLatin1String("")); arg = arg.replace(QLatin1String("\""), QLatin1String(""));
if (!result.contains(arg)) if (!result.contains(arg))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment