Commit e7a18108 authored by Christian Kandeler's avatar Christian Kandeler

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
const QString &toolchainType)
{
QStringList result;
const QString option = QLatin1String(toolchainType == QLatin1String("msvc") ? "/D" : "-D");
foreach (QByteArray def, defines.split('\n')) {
if (def.isEmpty())
......@@ -535,12 +534,11 @@ QStringList CompilerOptionsBuilder::createDefineOptions(const QByteArray &define
QByteArray str = def.mid(8);
int spaceIdx = str.indexOf(' ');
QString arg;
if (spaceIdx != -1) {
arg = option + QLatin1String(str.left(spaceIdx) + "=" + str.mid(spaceIdx + 1));
} else {
arg = option + QLatin1String(str);
}
const QString option = QLatin1String(toolchainType == QLatin1String("msvc") ? "/D" : "-D");
const bool hasValue = spaceIdx != -1;
QString arg = option + QLatin1String(str.left(hasValue ? spaceIdx : str.size()) + '=');
if (hasValue)
arg += QLatin1String(str.mid(spaceIdx + 1));
arg = arg.replace(QLatin1String("\\\""), QLatin1String("\""));
arg = arg.replace(QLatin1String("\""), QLatin1String(""));
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