forked from qt-creator/qt-creator
Add method to verify existence of CMake targets
* Add a simple method to test whether a CMake target exists. Reviewed-by: dt
This commit is contained in:
@@ -273,7 +273,7 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(cons
|
||||
m_project->parseCMakeLists();
|
||||
|
||||
// Default to all
|
||||
if (m_project->targets().contains("all"))
|
||||
if (m_project->hasTarget("all"))
|
||||
makeStep->setBuildTarget("all", true);
|
||||
return bc;
|
||||
}
|
||||
|
||||
@@ -319,6 +319,19 @@ QStringList CMakeProject::targets() const
|
||||
return results;
|
||||
}
|
||||
|
||||
bool CMakeProject::hasTarget(const QString &title) const
|
||||
{
|
||||
foreach (const CMakeTarget &ct, m_targets) {
|
||||
if (ct.executable.isEmpty())
|
||||
continue;
|
||||
if (ct.title.endsWith("/fast"))
|
||||
continue;
|
||||
if (ct.title == title)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CMakeProject::gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list)
|
||||
{
|
||||
foreach(ProjectExplorer::FolderNode *folder, parent->subFolderNodes())
|
||||
@@ -540,7 +553,7 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
if (!hasUserFile && targets().contains("all"))
|
||||
if (!hasUserFile && hasTarget("all"))
|
||||
makeStep->setBuildTarget("all", true);
|
||||
|
||||
m_lastActiveBuildConfiguration = activeCMakeBuildConfiguration();
|
||||
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
|
||||
virtual QStringList files(FilesMode fileMode) const;
|
||||
QStringList targets() const;
|
||||
bool hasTarget(const QString &title) const;
|
||||
|
||||
CMakeTarget targetForTitle(const QString &title);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user