CMake: Make CMakeConfig a proper class

Looks a bit more "object oriented" in my book.

Change-Id: I6a3b1b4691ec1c7465f652608678e8f31e7e52a7
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
hjk
2021-07-06 10:29:29 +02:00
parent 7aef03134d
commit 3aa324ef1f
8 changed files with 77 additions and 71 deletions

View File

@@ -515,7 +515,7 @@ void CMakeBuildSettingsWidget::batchEditConfiguration()
[expander](const QString &s) { [expander](const QString &s) {
return expander->expand(s); return expander->expand(s);
}); });
const CMakeConfig config = CMakeConfigItem::itemsFromArguments(expandedLines); const CMakeConfig config = CMakeConfig::fromArguments(expandedLines);
m_configModel->setBatchEditConfiguration(config); m_configModel->setBatchEditConfiguration(config);
}); });
@@ -1048,7 +1048,7 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
}(); }();
if (initialCMakeArguments().isEmpty()) { if (initialCMakeArguments().isEmpty()) {
QStringList initialArgs = defaultInitialCMakeArguments(kit(), buildTypeName) QStringList initialArgs = defaultInitialCMakeArguments(kit(), buildTypeName)
+ Utils::transform(conf, [this](const CMakeConfigItem &i) { + Utils::transform(conf.toList(), [this](const CMakeConfigItem &i) {
return i.toArgument(macroExpander()); return i.toArgument(macroExpander());
}); });
@@ -1110,7 +1110,8 @@ CMakeConfig CMakeBuildConfiguration::configurationChanges() const
QStringList CMakeBuildConfiguration::configurationChangesArguments() const QStringList CMakeBuildConfiguration::configurationChangesArguments() const
{ {
return Utils::transform(m_configurationChanges, [](const CMakeConfigItem &i) { return i.toArgument(); }); return Utils::transform(m_configurationChanges.toList(),
[](const CMakeConfigItem &i) { return i.toArgument(); });
} }
QStringList CMakeBuildConfiguration::initialCMakeArguments() const QStringList CMakeBuildConfiguration::initialCMakeArguments() const
@@ -1296,9 +1297,9 @@ BuildInfo CMakeBuildConfigurationFactory::createBuildInfo(BuildType buildType)
BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const
{ {
QByteArray cmakeBuildTypeName = CMakeConfigItem::valueOf("CMAKE_BUILD_TYPE", m_configurationFromCMake); QByteArray cmakeBuildTypeName = m_configurationFromCMake.valueOf("CMAKE_BUILD_TYPE");
if (cmakeBuildTypeName.isEmpty()) { if (cmakeBuildTypeName.isEmpty()) {
QByteArray cmakeCfgTypes = CMakeConfigItem::valueOf("CMAKE_CONFIGURATION_TYPES", m_configurationFromCMake); QByteArray cmakeCfgTypes = m_configurationFromCMake.valueOf("CMAKE_CONFIGURATION_TYPES");
if (!cmakeCfgTypes.isEmpty()) if (!cmakeCfgTypes.isEmpty())
cmakeBuildTypeName = cmakeBuildType().toUtf8(); cmakeBuildTypeName = cmakeBuildType().toUtf8();
} }
@@ -1352,14 +1353,14 @@ QString CMakeBuildConfiguration::cmakeBuildType() const
QString errorMessage; QString errorMessage;
config = CMakeBuildSystem::parseCMakeCacheDotTxt(cmakeCacheTxt, &errorMessage); config = CMakeBuildSystem::parseCMakeCacheDotTxt(cmakeCacheTxt, &errorMessage);
} else { } else {
config = CMakeConfigItem::itemsFromArguments(initialCMakeArguments()); config = CMakeConfig::fromArguments(initialCMakeArguments());
} }
} else if (!hasCMakeCache) { } else if (!hasCMakeCache) {
config = CMakeConfigItem::itemsFromArguments(initialCMakeArguments()); config = CMakeConfig::fromArguments(initialCMakeArguments());
} }
if (!config.isEmpty() && !isMultiConfig()) { if (!config.isEmpty() && !isMultiConfig()) {
cmakeBuildType = CMakeConfigItem::stringValueOf("CMAKE_BUILD_TYPE", config); cmakeBuildType = config.stringValueOf("CMAKE_BUILD_TYPE");
const_cast<CMakeBuildConfiguration*>(this)->setCMakeBuildType(cmakeBuildType); const_cast<CMakeBuildConfiguration*>(this)->setCMakeBuildType(cmakeBuildType);
} }

View File

@@ -838,7 +838,7 @@ void CMakeBuildSystem::wireUpConnections()
QString errorMessage; QString errorMessage;
const CMakeConfig config = CMakeBuildSystem::parseCMakeCacheDotTxt(cmakeCacheTxt, &errorMessage); const CMakeConfig config = CMakeBuildSystem::parseCMakeCacheDotTxt(cmakeCacheTxt, &errorMessage);
if (!config.isEmpty() && errorMessage.isEmpty()) { if (!config.isEmpty() && errorMessage.isEmpty()) {
QString cmakeBuildTypeName = CMakeConfigItem::stringValueOf("CMAKE_BUILD_TYPE", config); QString cmakeBuildTypeName = config.stringValueOf("CMAKE_BUILD_TYPE");
cmakeBuildConfiguration()->setCMakeBuildType(cmakeBuildTypeName, true); cmakeBuildConfiguration()->setCMakeBuildType(cmakeBuildTypeName, true);
} }
} }
@@ -1057,7 +1057,7 @@ CMakeConfig CMakeBuildSystem::parseCMakeCacheDotTxt(const Utils::FilePath &cache
*errorMessage = tr("CMakeCache.txt file not found."); *errorMessage = tr("CMakeCache.txt file not found.");
return {}; return {};
} }
CMakeConfig result = CMakeConfigItem::itemsFromFile(cacheFile, errorMessage); CMakeConfig result = CMakeConfig::fromFile(cacheFile, errorMessage);
if (!errorMessage->isEmpty()) if (!errorMessage->isEmpty())
return {}; return {};
return result; return result;
@@ -1210,7 +1210,7 @@ void CMakeBuildSystem::updateQmlJSCodeModel(const QStringList &extraHeaderPaths,
}; };
const CMakeConfig &cm = cmakeBuildConfiguration()->configurationFromCMake(); const CMakeConfig &cm = cmakeBuildConfiguration()->configurationFromCMake();
addImports(CMakeConfigItem::stringValueOf("QML_IMPORT_PATH", cm)); addImports(cm.stringValueOf("QML_IMPORT_PATH"));
addImports(kit()->value(QtSupport::KitQmlImportPath::id()).toString()); addImports(kit()->value(QtSupport::KitQmlImportPath::id()).toString());
for (const QString &extraHeaderPath : extraHeaderPaths) for (const QString &extraHeaderPath : extraHeaderPaths)
@@ -1244,7 +1244,7 @@ void CMakeBuildSystem::updateInitialCMakeExpandableVars()
{ {
const CMakeConfig &cm = cmakeBuildConfiguration()->configurationFromCMake(); const CMakeConfig &cm = cmakeBuildConfiguration()->configurationFromCMake();
const CMakeConfig &initialConfig = const CMakeConfig &initialConfig =
CMakeConfigItem::itemsFromArguments(cmakeBuildConfiguration()->initialCMakeArguments()); CMakeConfig::fromArguments(cmakeBuildConfiguration()->initialCMakeArguments());
CMakeConfig config; CMakeConfig config;
@@ -1275,7 +1275,7 @@ void CMakeBuildSystem::updateInitialCMakeExpandableVars()
}); });
if (it != cm.cend()) { if (it != cm.cend()) {
const QByteArray initialValue = CMakeConfigItem::expandedValueOf(kit(), var, initialConfig).toUtf8(); const QByteArray initialValue = initialConfig.expandedValueOf(kit(), var).toUtf8();
const FilePath initialPath = FilePath::fromString(QString::fromUtf8(initialValue)); const FilePath initialPath = FilePath::fromString(QString::fromUtf8(initialValue));
const FilePath path = FilePath::fromString(QString::fromUtf8(it->value)); const FilePath path = FilePath::fromString(QString::fromUtf8(it->value));
@@ -1299,7 +1299,7 @@ void CMakeBuildSystem::updateInitialCMakeExpandableVars()
}); });
if (it != cm.cend()) { if (it != cm.cend()) {
const QByteArrayList initialValueList = CMakeConfigItem::expandedValueOf(kit(), var, initialConfig).toUtf8().split(';'); const QByteArrayList initialValueList = initialConfig.expandedValueOf(kit(), var).toUtf8().split(';');
for (const auto &initialValue: initialValueList) { for (const auto &initialValue: initialValueList) {
const FilePath initialPath = FilePath::fromString(QString::fromUtf8(initialValue)); const FilePath initialPath = FilePath::fromString(QString::fromUtf8(initialValue));

View File

@@ -55,29 +55,28 @@ CMakeConfigItem::CMakeConfigItem(const QByteArray &k, const QByteArray &v) :
key(k), value(v) key(k), value(v)
{ } { }
QByteArray CMakeConfigItem::valueOf(const QByteArray &key, const QList<CMakeConfigItem> &input) QByteArray CMakeConfig::valueOf(const QByteArray &key) const
{ {
for (auto it = input.constBegin(); it != input.constEnd(); ++it) { for (auto it = constBegin(); it != constEnd(); ++it) {
if (it->key == key) if (it->key == key)
return it->value; return it->value;
} }
return QByteArray(); return QByteArray();
} }
QString CMakeConfigItem::stringValueOf(const QByteArray &key, const QList<CMakeConfigItem> &input) QString CMakeConfig::stringValueOf(const QByteArray &key) const
{ {
return QString::fromUtf8(valueOf(key, input)); return QString::fromUtf8(valueOf(key));
} }
FilePath CMakeConfigItem::filePathValueOf(const QByteArray &key, const QList<CMakeConfigItem> &input) FilePath CMakeConfig::filePathValueOf(const QByteArray &key) const
{ {
return FilePath::fromUtf8(valueOf(key, input)); return FilePath::fromUtf8(valueOf(key));
} }
QString CMakeConfigItem::expandedValueOf(const ProjectExplorer::Kit *k, const QByteArray &key, QString CMakeConfig::expandedValueOf(const ProjectExplorer::Kit *k, const QByteArray &key) const
const QList<CMakeConfigItem> &input)
{ {
for (auto it = input.constBegin(); it != input.constEnd(); ++it) { for (auto it = constBegin(); it != constEnd(); ++it) {
if (it->key == key) if (it->key == key)
return it->expandedValue(k); return it->expandedValue(k);
} }
@@ -312,7 +311,7 @@ static CMakeConfigItem unsetItemFromString(const QString &input)
return item; return item;
} }
QList<CMakeConfigItem> CMakeConfigItem::itemsFromArguments(const QStringList &list) CMakeConfig CMakeConfig::fromArguments(const QStringList &list)
{ {
CMakeConfig result; CMakeConfig result;
bool inSet = false; bool inSet = false;
@@ -348,7 +347,7 @@ QList<CMakeConfigItem> CMakeConfigItem::itemsFromArguments(const QStringList &li
return result; return result;
} }
QList<CMakeConfigItem> CMakeConfigItem::itemsFromFile(const Utils::FilePath &cacheFile, QString *errorMessage) CMakeConfig CMakeConfig::fromFile(const Utils::FilePath &cacheFile, QString *errorMessage)
{ {
CMakeConfig result; CMakeConfig result;
QFile cache(cacheFile.toString()); QFile cache(cacheFile.toString());

View File

@@ -43,18 +43,16 @@ class Kit;
namespace CMakeProjectManager { namespace CMakeProjectManager {
class CMAKE_EXPORT CMakeConfigItem { class CMakeConfig;
class CMAKE_EXPORT CMakeConfigItem
{
public: public:
enum Type { FILEPATH, PATH, BOOL, STRING, INTERNAL, STATIC, UNINITIALIZED }; enum Type { FILEPATH, PATH, BOOL, STRING, INTERNAL, STATIC, UNINITIALIZED };
CMakeConfigItem(); CMakeConfigItem();
CMakeConfigItem(const QByteArray &k, Type t, const QByteArray &d, const QByteArray &v, const QStringList &s = {}); CMakeConfigItem(const QByteArray &k, Type t, const QByteArray &d, const QByteArray &v, const QStringList &s = {});
CMakeConfigItem(const QByteArray &k, const QByteArray &v); CMakeConfigItem(const QByteArray &k, const QByteArray &v);
static QByteArray valueOf(const QByteArray &key, const QList<CMakeConfigItem> &input);
static QString stringValueOf(const QByteArray &key, const QList<CMakeConfigItem> &input);
static Utils::FilePath filePathValueOf(const QByteArray &key, const QList<CMakeConfigItem> &input);
static QString expandedValueOf(const ProjectExplorer::Kit *k, const QByteArray &key,
const QList<CMakeConfigItem> &input);
static QStringList cmakeSplitValue(const QString &in, bool keepEmpty = false); static QStringList cmakeSplitValue(const QString &in, bool keepEmpty = false);
static Type typeStringToType(const QByteArray &typeString); static Type typeStringToType(const QByteArray &typeString);
static QString typeToTypeString(const Type t); static QString typeToTypeString(const Type t);
@@ -66,8 +64,6 @@ public:
static bool less(const CMakeConfigItem &a, const CMakeConfigItem &b); static bool less(const CMakeConfigItem &a, const CMakeConfigItem &b);
static CMakeConfigItem fromString(const QString &s); static CMakeConfigItem fromString(const QString &s);
static QList<CMakeConfigItem> itemsFromArguments(const QStringList &list);
static QList<CMakeConfigItem> itemsFromFile(const Utils::FilePath &input, QString *errorMessage);
QString toString(const Utils::MacroExpander *expander = nullptr) const; QString toString(const Utils::MacroExpander *expander = nullptr) const;
QString toArgument(const Utils::MacroExpander *expander = nullptr) const; QString toArgument(const Utils::MacroExpander *expander = nullptr) const;
QString toCMakeSetLine(const Utils::MacroExpander *expander = nullptr) const; QString toCMakeSetLine(const Utils::MacroExpander *expander = nullptr) const;
@@ -83,6 +79,23 @@ public:
QByteArray documentation; QByteArray documentation;
QStringList values; QStringList values;
}; };
using CMakeConfig = QList<CMakeConfigItem>;
class CMAKE_EXPORT CMakeConfig : public QList<CMakeConfigItem>
{
public:
CMakeConfig() = default;
CMakeConfig(const QList<CMakeConfigItem> &items) : QList<CMakeConfigItem>(items) {}
CMakeConfig(std::initializer_list<CMakeConfigItem> items) : QList<CMakeConfigItem>(items) {}
const QList<CMakeConfigItem> &toList() const { return *this; }
static CMakeConfig fromArguments(const QStringList &list);
static CMakeConfig fromFile(const Utils::FilePath &input, QString *errorMessage);
QByteArray valueOf(const QByteArray &key) const;
QString stringValueOf(const QByteArray &key) const;
Utils::FilePath filePathValueOf(const QByteArray &key) const;
QString expandedValueOf(const ProjectExplorer::Kit *k, const QByteArray &key) const;
};
} // namespace CMakeProjectManager } // namespace CMakeProjectManager

View File

@@ -996,15 +996,15 @@ void CMakeConfigurationKitAspect::setConfiguration(Kit *k, const CMakeConfig &co
{ {
if (!k) if (!k)
return; return;
const QStringList tmp = Utils::transform(config, [](const CMakeConfigItem &i) { return i.toString(); }); const QStringList tmp = Utils::transform(config.toList(),
[](const CMakeConfigItem &i) { return i.toString(); });
k->setValue(CONFIGURATION_ID, tmp); k->setValue(CONFIGURATION_ID, tmp);
} }
QStringList CMakeConfigurationKitAspect::toStringList(const Kit *k) QStringList CMakeConfigurationKitAspect::toStringList(const Kit *k)
{ {
QStringList current QStringList current = Utils::transform(CMakeConfigurationKitAspect::configuration(k).toList(),
= Utils::transform(CMakeConfigurationKitAspect::configuration(k), [](const CMakeConfigItem &i) { return i.toString(); });
[](const CMakeConfigItem &i) { return i.toString(); });
current = Utils::filtered(current, [](const QString &s) { return !s.isEmpty(); }); current = Utils::filtered(current, [](const QString &s) { return !s.isEmpty(); });
Utils::sort(current); Utils::sort(current);
return current; return current;
@@ -1023,7 +1023,7 @@ void CMakeConfigurationKitAspect::fromStringList(Kit *k, const QStringList &in)
QStringList CMakeConfigurationKitAspect::toArgumentsList(const Kit *k) QStringList CMakeConfigurationKitAspect::toArgumentsList(const Kit *k)
{ {
return Utils::transform(CMakeConfigurationKitAspect::configuration(k), return Utils::transform(CMakeConfigurationKitAspect::configuration(k).toList(),
[](const CMakeConfigItem &i) { return i.toArgument(nullptr); }); [](const CMakeConfigItem &i) { return i.toArgument(nullptr); });
} }
@@ -1046,8 +1046,8 @@ QVariant CMakeConfigurationKitAspect::defaultValue(const Kit *k) const
{ {
// FIXME: Convert preload scripts // FIXME: Convert preload scripts
CMakeConfig config = defaultConfiguration(k); CMakeConfig config = defaultConfiguration(k);
const QStringList tmp const QStringList tmp = Utils::transform(config.toList(),
= Utils::transform(config, [](const CMakeConfigItem &i) { return i.toString(); }); [](const CMakeConfigItem &i) { return i.toString(); });
return tmp; return tmp;
} }

View File

@@ -135,20 +135,16 @@ QStringList CMakeProjectImporter::importCandidates()
static FilePath qmakeFromCMakeCache(const CMakeConfig &config) static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
{ {
// Qt4 way to define things (more convenient for us, so try this first;-) // Qt4 way to define things (more convenient for us, so try this first;-)
FilePath qmake const FilePath qmake = config.filePathValueOf("QT_QMAKE_EXECUTABLE");
= FilePath::fromUtf8(CMakeConfigItem::valueOf(QByteArray("QT_QMAKE_EXECUTABLE"), config));
qCDebug(cmInputLog) << "QT_QMAKE_EXECUTABLE=" << qmake.toUserOutput(); qCDebug(cmInputLog) << "QT_QMAKE_EXECUTABLE=" << qmake.toUserOutput();
if (!qmake.isEmpty()) if (!qmake.isEmpty())
return qmake; return qmake;
// Check Qt5 settings: oh, the horror! // Check Qt5 settings: oh, the horror!
const FilePath qtCMakeDir = [config] { const FilePath qtCMakeDir = [config] {
FilePath tmp = FilePath::fromUtf8( FilePath tmp = config.filePathValueOf("Qt5Core_DIR");
CMakeConfigItem::valueOf(QByteArray("Qt5Core_DIR"), config)); if (tmp.isEmpty())
if (tmp.isEmpty()) { tmp = config.filePathValueOf("Qt6Core_DIR");
tmp = FilePath::fromUtf8(
CMakeConfigItem::valueOf(QByteArray("Qt6Core_DIR"), config));
}
return tmp; return tmp;
}(); }();
qCDebug(cmInputLog) << "QtXCore_DIR=" << qtCMakeDir.toUserOutput(); qCDebug(cmInputLog) << "QtXCore_DIR=" << qtCMakeDir.toUserOutput();
@@ -206,11 +202,11 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
cmake.setEnvironment(env); cmake.setEnvironment(env);
cmake.setTimeOutMessageBoxEnabled(false); cmake.setTimeOutMessageBoxEnabled(false);
QString cmakeGenerator = CMakeConfigItem::stringValueOf(QByteArray("CMAKE_GENERATOR"), config); QString cmakeGenerator = config.stringValueOf(QByteArray("CMAKE_GENERATOR"));
FilePath cmakeExecutable = CMakeConfigItem::filePathValueOf(QByteArray("CMAKE_COMMAND"), config); FilePath cmakeExecutable = config.filePathValueOf(QByteArray("CMAKE_COMMAND"));
FilePath cmakeMakeProgram =CMakeConfigItem::filePathValueOf(QByteArray("CMAKE_MAKE_PROGRAM"), config); FilePath cmakeMakeProgram = config.filePathValueOf(QByteArray("CMAKE_MAKE_PROGRAM"));
FilePath toolchainFile = CMakeConfigItem::filePathValueOf(QByteArray("CMAKE_TOOLCHAIN_FILE"), config); FilePath toolchainFile = config.filePathValueOf(QByteArray("CMAKE_TOOLCHAIN_FILE"));
FilePath hostPath = CMakeConfigItem::filePathValueOf(QByteArray("QT_HOST_PATH"), config); FilePath hostPath = config.filePathValueOf(QByteArray("QT_HOST_PATH"));
QStringList args; QStringList args;
args.push_back("-S"); args.push_back("-S");
@@ -270,7 +266,7 @@ static QVector<ToolChainDescription> extractToolChainsFromCache(const CMakeConfi
} }
if (!haveCCxxCompiler) { if (!haveCCxxCompiler) {
const QByteArray generator = CMakeConfigItem::valueOf(QByteArray("CMAKE_GENERATOR"), config); const QByteArray generator = config.valueOf("CMAKE_GENERATOR");
QString cCompilerName; QString cCompilerName;
QString cxxCompilerName; QString cxxCompilerName;
if (generator.contains("Visual Studio")) { if (generator.contains("Visual Studio")) {
@@ -282,8 +278,7 @@ static QVector<ToolChainDescription> extractToolChainsFromCache(const CMakeConfi
} }
if (!cCompilerName.isEmpty() && !cxxCompilerName.isEmpty()) { if (!cCompilerName.isEmpty() && !cxxCompilerName.isEmpty()) {
const FilePath linker = FilePath::fromUtf8( const FilePath linker = config.filePathValueOf("CMAKE_LINKER");
CMakeConfigItem::valueOf(QByteArray("CMAKE_LINKER"), config));
if (!linker.isEmpty()) { if (!linker.isEmpty()) {
const FilePath compilerPath = linker.parentDir(); const FilePath compilerPath = linker.parentDir();
result.append({compilerPath.pathAppended(cCompilerName), result.append({compilerPath.pathAppended(cCompilerName),
@@ -315,13 +310,11 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
return { }; return { };
} }
QByteArrayList buildConfigurationTypes = {CMakeConfigItem::valueOf("CMAKE_BUILD_TYPE", config)}; QByteArrayList buildConfigurationTypes = {config.valueOf("CMAKE_BUILD_TYPE")};
if (buildConfigurationTypes.front().isEmpty()) { if (buildConfigurationTypes.front().isEmpty()) {
QByteArray buildConfigurationTypesString = QByteArray buildConfigurationTypesString = config.valueOf("CMAKE_CONFIGURATION_TYPES");
CMakeConfigItem::valueOf("CMAKE_CONFIGURATION_TYPES", config); if (!buildConfigurationTypesString.isEmpty())
if (!buildConfigurationTypesString.isEmpty()) {
buildConfigurationTypes = buildConfigurationTypesString.split(';'); buildConfigurationTypes = buildConfigurationTypesString.split(';');
}
} }
QList<void *> result; QList<void *> result;
@@ -329,7 +322,7 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
auto data = std::make_unique<DirectoryData>(); auto data = std::make_unique<DirectoryData>();
data->cmakeHomeDirectory = data->cmakeHomeDirectory =
FilePath::fromUserInput(CMakeConfigItem::stringValueOf("CMAKE_HOME_DIRECTORY", config)) FilePath::fromUserInput(config.stringValueOf("CMAKE_HOME_DIRECTORY"))
.canonicalPath(); .canonicalPath();
const FilePath canonicalProjectDirectory = projectDirectory().canonicalPath(); const FilePath canonicalProjectDirectory = projectDirectory().canonicalPath();
if (data->cmakeHomeDirectory != canonicalProjectDirectory) { if (data->cmakeHomeDirectory != canonicalProjectDirectory) {
@@ -344,12 +337,12 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
data->buildDirectory = importPath; data->buildDirectory = importPath;
data->cmakeBuildType = buildType; data->cmakeBuildType = buildType;
data->cmakeBinary = CMakeConfigItem::filePathValueOf("CMAKE_COMMAND", config); data->cmakeBinary = config.filePathValueOf("CMAKE_COMMAND");
data->generator = CMakeConfigItem::stringValueOf("CMAKE_GENERATOR", config); data->generator = config.stringValueOf("CMAKE_GENERATOR");
data->extraGenerator = CMakeConfigItem::stringValueOf("CMAKE_EXTRA_GENERATOR", config); data->extraGenerator = config.stringValueOf("CMAKE_EXTRA_GENERATOR");
data->platform = CMakeConfigItem::stringValueOf("CMAKE_GENERATOR_PLATFORM", config); data->platform = config.stringValueOf("CMAKE_GENERATOR_PLATFORM");
data->toolset = CMakeConfigItem::stringValueOf("CMAKE_GENERATOR_TOOLSET", config); data->toolset = config.stringValueOf("CMAKE_GENERATOR_TOOLSET");
data->sysroot = CMakeConfigItem::filePathValueOf("CMAKE_SYSROOT", config); data->sysroot = config.filePathValueOf("CMAKE_SYSROOT");
// Qt: // Qt:
const FilePath qmake = qmakeFromCMakeCache(config); const FilePath qmake = qmakeFromCMakeCache(config);

View File

@@ -203,7 +203,7 @@ QList<ConfigModel::DataItem> ConfigModel::configurationForCMake() const
void ConfigModel::setConfiguration(const CMakeConfig &config) void ConfigModel::setConfiguration(const CMakeConfig &config)
{ {
setConfiguration(Utils::transform(config, [](const CMakeConfigItem &i) { setConfiguration(Utils::transform(config.toList(), [](const CMakeConfigItem &i) {
return DataItem(i); return DataItem(i);
})); }));
} }

View File

@@ -337,7 +337,7 @@ void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &conf
QByteArray contents; QByteArray contents;
contents.append("# This file is managed by Qt Creator, do not edit!\n\n"); contents.append("# This file is managed by Qt Creator, do not edit!\n\n");
contents.append( contents.append(
transform(CMakeConfigItem::itemsFromArguments(configurationArguments), transform(CMakeConfig::fromArguments(configurationArguments).toList(),
[](const CMakeConfigItem &item) { [](const CMakeConfigItem &item) {
return item.toCMakeSetLine(nullptr); return item.toCMakeSetLine(nullptr);
}) })