Commit 7276da82 authored by Tobias Hunger's avatar Tobias Hunger Committed by Tobias Hunger

CMake: Reuse code to turn CMakeConfigItems into strings

Change-Id: Iecb553ce562e22daa5429cef431fe12994637f9a
Reviewed-by: default avatarVikas Pachdha <vikas.pachdha@theqtcompany.com>
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent cf0e087a
......@@ -61,30 +61,13 @@ namespace CMakeProjectManager {
namespace Internal {
static QStringList toArguments(const CMakeConfig &config, const ProjectExplorer::Kit *k) {
return Utils::transform(config, [k](const CMakeConfigItem &i) -> QString {
QString a = QString::fromLatin1("-D");
a.append(QString::fromUtf8(i.key));
switch (i.type) {
case CMakeConfigItem::FILEPATH:
a.append(QLatin1String(":FILEPATH="));
break;
case CMakeConfigItem::PATH:
a.append(QLatin1String(":PATH="));
break;
case CMakeConfigItem::BOOL:
a.append(QLatin1String(":BOOL="));
break;
case CMakeConfigItem::STRING:
a.append(QLatin1String(":STRING="));
break;
case CMakeConfigItem::INTERNAL:
a.append(QLatin1String(":INTERNAL="));
break;
}
a.append(QString::fromUtf8(k->macroExpander()->expand(i.value)));
return a;
});
const QStringList argList
= Utils::transform(config, [k](const CMakeConfigItem &i) -> QString {
const QString tmp = i.toString();
return tmp.isEmpty() ? QString()
: QString::fromLatin1("-D") + k->macroExpander()->expand(tmp);
});
return Utils::filtered(argList, [](const QString &s) { return !s.isEmpty(); });
}
// --------------------------------------------------------------------
......
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