Commit 83ae0cb9 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Mark cmake as imperfect and disable RunConfigurations as necessary

CMake does not know whether a build target was configured out of the
current build or removed entirely, so implement the relevant marker.

Mark all of the "vanished" RunConfigurations as disabled.

Also remove one unnecessary level of indirection when setting up
RunConfigurations.

Change-Id: I30a21581823b4bff5a5be29480e64423b9379983
Task-number: QTCREATORBUG-15950
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent c0185305
......@@ -219,6 +219,7 @@ void CMakeProject::parseCMakeOutput()
bdm->clearFiles(); // Some of the FileNodes in files() were deleted!
updateApplicationAndDeploymentTargets();
updateTargetRunConfigurations(t);
createGeneratedCodeModelSupport();
......@@ -267,8 +268,6 @@ void CMakeProject::parseCMakeOutput()
emit fileListChanged();
emit cmakeBc->emitBuildTypeChanged();
updateRunConfigurations();
}
bool CMakeProject::needsConfiguration() const
......@@ -281,6 +280,11 @@ bool CMakeProject::requiresTargetPanel() const
return !targets().isEmpty();
}
bool CMakeProject::knowsAllBuildExecutables() const
{
return false;
}
bool CMakeProject::supportsKit(Kit *k, QString *errorMessage) const
{
if (!CMakeKitInformation::cmakeTool(k)) {
......@@ -549,46 +553,33 @@ QStringList CMakeProject::filesGeneratedFrom(const QString &sourceFile) const
}
}
void CMakeProject::updateRunConfigurations()
{
foreach (Target *t, targets())
updateTargetRunConfigurations(t);
}
// TODO Compare with updateDefaultRunConfigurations();
void CMakeProject::updateTargetRunConfigurations(Target *t)
{
// create new and remove obsolete RCs using the factories
t->updateDefaultRunConfigurations();
// *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;
// *Update* runconfigurations:
QMultiMap<QString, CMakeRunConfiguration*> existingRunConfigurations;
foreach (ProjectExplorer::RunConfiguration *rc, t->runConfigurations()) {
if (CMakeRunConfiguration* cmakeRC = qobject_cast<CMakeRunConfiguration *>(rc))
existingRunConfigurations.insert(cmakeRC->title(), cmakeRC);
buildTargetHash.insert(bt.title, &bt);
}
foreach (const CMakeBuildTarget &ct, buildTargets()) {
if (ct.targetType != ExecutableType)
foreach (RunConfiguration *rc, t->runConfigurations()) {
auto cmakeRc = qobject_cast<CMakeRunConfiguration *>(rc);
if (!cmakeRc)
continue;
if (ct.executable.isEmpty())
continue;
QList<CMakeRunConfiguration *> list = existingRunConfigurations.values(ct.title);
if (!list.isEmpty()) {
// Already exists, so override the settings...
foreach (CMakeRunConfiguration *rc, list) {
rc->setExecutable(ct.executable);
rc->setBaseWorkingDirectory(ct.workingDirectory);
rc->setEnabled(true);
}
auto btIt = buildTargetHash.constFind(cmakeRc->title());
cmakeRc->setEnabled(btIt != buildTargetHash.constEnd());
if (btIt != buildTargetHash.constEnd()) {
cmakeRc->setExecutable(btIt.value()->executable);
cmakeRc->setBaseWorkingDirectory(btIt.value()->workingDirectory);
}
}
if (t->runConfigurations().isEmpty()) {
// Oh no, no run configuration,
// create a custom executable run configuration
t->addRunConfiguration(new QtSupport::CustomExecutableRunConfiguration(t));
}
// create new and remove obsolete RCs using the factories
t->updateDefaultRunConfigurations();
}
void CMakeProject::updateApplicationAndDeploymentTargets()
......
......@@ -105,6 +105,7 @@ public:
bool needsConfiguration() const override;
bool requiresTargetPanel() const override;
bool knowsAllBuildExecutables() const override;
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage = 0) const override;
......@@ -124,8 +125,6 @@ private:
void handleParsingStarted();
void parseCMakeOutput();
void updateRunConfigurations();
void buildTree(Internal::CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list) const;
ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory);
......
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