Commit 17977b3d authored by Tobias Hunger's avatar Tobias Hunger
Browse files

CMake: Turn CMakeConfigItem into a CMake argument



Add a method to turn a CMakeConfigItem into a string suitable to be passed
to CMake.

Change-Id: Ia7834f1c2fad387dd6e6eaa3863f93385d48ca71
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent cc909089
......@@ -72,31 +72,7 @@ namespace Internal {
static QStringList toArguments(const CMakeConfig &config, const 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;
case CMakeConfigItem::STATIC:
a.append(QLatin1String(":STATIC="));
break;
}
a.append(i.expandedValue(k));
return a;
return i.toArgument(k->macroExpander());
});
}
......
......@@ -245,6 +245,11 @@ QString CMakeConfigItem::toString(const Utils::MacroExpander *expander) const
return QString::fromUtf8(key) + QLatin1Char(':') + typeStr + QLatin1Char('=') + expandedValue;
}
QString CMakeConfigItem::toArgument(const Utils::MacroExpander *expander) const
{
return "-D" + toString(expander);
}
bool CMakeConfigItem::operator==(const CMakeConfigItem &o) const
{
// type, isAdvanced and documentation do not matter for a match!
......
......@@ -55,6 +55,7 @@ public:
static std::function<bool(const CMakeConfigItem &a, const CMakeConfigItem &b)> sortOperator();
static CMakeConfigItem fromString(const QString &s);
QString toString(const Utils::MacroExpander *expander = nullptr) const;
QString toArgument(const Utils::MacroExpander *expander = nullptr) const;
bool operator==(const CMakeConfigItem &o) const;
......
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