Commit 38f30e73 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Always show CMakeLists.txt in project tree

Always show the top level CMakeLists.txt file in the project tree,
even when parsing failed.

Change-Id: I42c844eb54b32fcb51131ad63a8fc372622636fc
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 9c09ca9e
......@@ -331,8 +331,7 @@ void BuildDirManager::generateProjectTree(CMakeProjectNode *root)
const Utils::FileName projectFile = m_buildConfiguration->target()->project()->projectFilePath();
QList<FileNode *> tmp = Utils::filtered(m_futureInterface->future().result(),
[projectFile](const FileNode *fn) -> bool {
const Utils::FileName &path = fn->filePath();
return path != projectFile && !path.toString().startsWith(projectFile.toString() + ".user");
return !fn->filePath().toString().startsWith(projectFile.toString() + ".user");
});
Utils::sort(tmp, ProjectExplorer::Node::sortByPath);
......@@ -344,6 +343,19 @@ void BuildDirManager::generateProjectTree(CMakeProjectNode *root)
foreach (FileNode *fn, root->recursiveFileNodes())
usedNodes.insert(fn);
// Make sure the top level CMakeLists.txt is always visible:
if (root->fileNodes().isEmpty()
&& root->folderNodes().isEmpty()
&& root->projectNodes().isEmpty()) {
FileNode *cm = Utils::findOrDefault(allFiles, [&projectFile](const FileNode *fn) {
return fn->filePath() == projectFile;
});
if (cm) {
root->addFileNodes({ cm });
usedNodes.insert(cm);
}
}
QList<FileNode *> leftOvers = Utils::filtered(allFiles, [&usedNodes](FileNode *fn) {
return !usedNodes.contains(fn);
});
......
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