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!
|
bdm->clearFiles(); // Some of the FileNodes in files() were deleted!
|
||||||
|
|
||||||
updateApplicationAndDeploymentTargets();
|
updateApplicationAndDeploymentTargets();
|
||||||
|
updateTargetRunConfigurations(t);
|
||||||
|
|
||||||
createGeneratedCodeModelSupport();
|
createGeneratedCodeModelSupport();
|
||||||
|
|
||||||
@@ -267,8 +268,6 @@ void CMakeProject::parseCMakeOutput()
|
|||||||
emit fileListChanged();
|
emit fileListChanged();
|
||||||
|
|
||||||
emit cmakeBc->emitBuildTypeChanged();
|
emit cmakeBc->emitBuildTypeChanged();
|
||||||
|
|
||||||
updateRunConfigurations();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMakeProject::needsConfiguration() const
|
bool CMakeProject::needsConfiguration() const
|
||||||
@@ -281,6 +280,11 @@ bool CMakeProject::requiresTargetPanel() const
|
|||||||
return !targets().isEmpty();
|
return !targets().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CMakeProject::knowsAllBuildExecutables() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CMakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
bool CMakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||||
{
|
{
|
||||||
if (!CMakeKitInformation::cmakeTool(k)) {
|
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)
|
void CMakeProject::updateTargetRunConfigurations(Target *t)
|
||||||
{
|
{
|
||||||
// create new and remove obsolete RCs using the factories
|
// *Update* existing runconfigurations (no need to update new ones!):
|
||||||
t->updateDefaultRunConfigurations();
|
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:
|
buildTargetHash.insert(bt.title, &bt);
|
||||||
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()) {
|
foreach (RunConfiguration *rc, t->runConfigurations()) {
|
||||||
if (ct.targetType != ExecutableType)
|
auto cmakeRc = qobject_cast<CMakeRunConfiguration *>(rc);
|
||||||
|
if (!cmakeRc)
|
||||||
continue;
|
continue;
|
||||||
if (ct.executable.isEmpty())
|
|
||||||
continue;
|
auto btIt = buildTargetHash.constFind(cmakeRc->title());
|
||||||
QList<CMakeRunConfiguration *> list = existingRunConfigurations.values(ct.title);
|
cmakeRc->setEnabled(btIt != buildTargetHash.constEnd());
|
||||||
if (!list.isEmpty()) {
|
if (btIt != buildTargetHash.constEnd()) {
|
||||||
// Already exists, so override the settings...
|
cmakeRc->setExecutable(btIt.value()->executable);
|
||||||
foreach (CMakeRunConfiguration *rc, list) {
|
cmakeRc->setBaseWorkingDirectory(btIt.value()->workingDirectory);
|
||||||
rc->setExecutable(ct.executable);
|
|
||||||
rc->setBaseWorkingDirectory(ct.workingDirectory);
|
|
||||||
rc->setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->runConfigurations().isEmpty()) {
|
// create new and remove obsolete RCs using the factories
|
||||||
// Oh no, no run configuration,
|
t->updateDefaultRunConfigurations();
|
||||||
// create a custom executable run configuration
|
|
||||||
t->addRunConfiguration(new QtSupport::CustomExecutableRunConfiguration(t));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeProject::updateApplicationAndDeploymentTargets()
|
void CMakeProject::updateApplicationAndDeploymentTargets()
|
||||||
|
@@ -105,6 +105,7 @@ public:
|
|||||||
|
|
||||||
bool needsConfiguration() const override;
|
bool needsConfiguration() const override;
|
||||||
bool requiresTargetPanel() const override;
|
bool requiresTargetPanel() const override;
|
||||||
|
bool knowsAllBuildExecutables() const override;
|
||||||
|
|
||||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage = 0) const override;
|
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage = 0) const override;
|
||||||
|
|
||||||
@@ -124,8 +125,6 @@ private:
|
|||||||
void handleParsingStarted();
|
void handleParsingStarted();
|
||||||
void parseCMakeOutput();
|
void parseCMakeOutput();
|
||||||
|
|
||||||
void updateRunConfigurations();
|
|
||||||
|
|
||||||
void buildTree(Internal::CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
|
void buildTree(Internal::CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
|
||||||
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list) const;
|
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list) const;
|
||||||
ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory);
|
ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory);
|
||||||
|
Reference in New Issue
Block a user