CMake: Set CMakeRunConfiguration executable and working directory

Since 131c7a1 the executable and base working directory property of
CMakeRunConfiguration objects is no longer set when the project data
is updated. At least the executable is required in the AutoTest plugin.

Change-Id: I31c4cb37983d3983664d178c0f8c08d491f719ad
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Claus Steuer
2017-09-17 20:01:41 +02:00
parent 68a49c79da
commit 100cd10d6e
2 changed files with 30 additions and 1 deletions

View File

@@ -152,7 +152,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
}
updateApplicationAndDeploymentTargets();
t->updateDefaultRunConfigurations();
updateTargetRunConfigurations(t);
createGeneratedCodeModelSupport();
@@ -448,6 +448,34 @@ QStringList CMakeProject::filesGeneratedFrom(const QString &sourceFile) const
}
}
void CMakeProject::updateTargetRunConfigurations(Target *t)
{
// *Update* existing runconfigurations (no need to update new ones!):
QHash<QString, const CMakeBuildTarget *> buildTargetHash;
const QList<CMakeBuildTarget> buildTargetList = buildTargets();
foreach (const CMakeBuildTarget &bt, buildTargetList) {
if (bt.targetType != ExecutableType || bt.executable.isEmpty())
continue;
buildTargetHash.insert(bt.title, &bt);
}
foreach (RunConfiguration *rc, t->runConfigurations()) {
auto cmakeRc = qobject_cast<CMakeRunConfiguration *>(rc);
if (!cmakeRc)
continue;
auto btIt = buildTargetHash.constFind(cmakeRc->title());
if (btIt != buildTargetHash.constEnd()) {
cmakeRc->setExecutable(btIt.value()->executable.toString());
cmakeRc->setBaseWorkingDirectory(btIt.value()->workingDirectory);
}
}
// create new and remove obsolete RCs using the factories
t->updateDefaultRunConfigurations();
}
void CMakeProject::updateApplicationAndDeploymentTargets()
{
Target *t = activeTarget();

View File

@@ -123,6 +123,7 @@ private:
void createGeneratedCodeModelSupport();
QStringList filesGeneratedFrom(const QString &sourceFile) const final;
void updateTargetRunConfigurations(ProjectExplorer::Target *t);
void updateApplicationAndDeploymentTargets();
ProjectExplorer::Target *m_connectedTarget = nullptr;