forked from qt-creator/qt-creator
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: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -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)
|
||||
{
|
||||
// *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());
|
||||
cmakeRc->setEnabled(btIt != buildTargetHash.constEnd());
|
||||
if (btIt != buildTargetHash.constEnd()) {
|
||||
cmakeRc->setExecutable(btIt.value()->executable);
|
||||
cmakeRc->setBaseWorkingDirectory(btIt.value()->workingDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
// create new and remove obsolete RCs using the factories
|
||||
t->updateDefaultRunConfigurations();
|
||||
|
||||
// *Update* runconfigurations:
|
||||
QMultiMap<QString, CMakeRunConfiguration*> existingRunConfigurations;
|
||||
foreach (ProjectExplorer::RunConfiguration *rc, t->runConfigurations()) {
|
||||
if (CMakeRunConfiguration* cmakeRC = qobject_cast<CMakeRunConfiguration *>(rc))
|
||||
existingRunConfigurations.insert(cmakeRC->title(), cmakeRC);
|
||||
}
|
||||
|
||||
foreach (const CMakeBuildTarget &ct, buildTargets()) {
|
||||
if (ct.targetType != ExecutableType)
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (t->runConfigurations().isEmpty()) {
|
||||
// Oh no, no run configuration,
|
||||
// create a custom executable run configuration
|
||||
t->addRunConfiguration(new QtSupport::CustomExecutableRunConfiguration(t));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user