CMake: Improve handling of cmake configuration in kits

Use macros. This makes it possible to address the current qt version
and toolchain without having to update those values all the time.

This significantly simplifies changing Qt versions and toolchains in
the kit as well as the code itself.

Change-Id: I35128eebdc96fe6175f565b2e9bdaa40862516a7
Task-number: QTCREATORBUG-15830
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-03-16 13:39:41 +01:00
parent ca805445fb
commit 5e623ddfd1
2 changed files with 13 additions and 37 deletions

View File

@@ -60,8 +60,8 @@
namespace CMakeProjectManager {
namespace Internal {
static QStringList toArguments(const CMakeConfig &config) {
return Utils::transform(config, [](const CMakeConfigItem &i) -> QString {
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) {
@@ -81,7 +81,7 @@ static QStringList toArguments(const CMakeConfig &config) {
a.append(QLatin1String(":INTERNAL="));
break;
}
a.append(QString::fromUtf8(i.value));
a.append(QString::fromUtf8(k->macroExpander()->expand(i.value)));
return a;
});
@@ -424,7 +424,7 @@ void BuildDirManager::startCMake(CMakeTool *tool, const QString &generator,
Utils::QtcProcess::addArg(&args, srcDir);
if (!generator.isEmpty())
Utils::QtcProcess::addArg(&args, QString::fromLatin1("-G%1").arg(generator));
Utils::QtcProcess::addArgs(&args, toArguments(config));
Utils::QtcProcess::addArgs(&args, toArguments(config, kit()));
ProjectExplorer::TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);