forked from qt-creator/qt-creator
CMake: Exclude non-project CMake files from search
All the CMake files the belong to packages found with `find_package` are part of the project tree, but we shouldn't include them when searching through "files in the project". Set listInProjects to false for these files. Fixes: QTCREATORBUG-30372 Change-Id: If39d477f14dc3207f4e2dd66b2f3969811dbd863 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -35,7 +35,8 @@ void addCMakeVFolder(FolderNode *base,
|
||||
int priority,
|
||||
const QString &displayName,
|
||||
std::vector<std::unique_ptr<FileNode>> &&files,
|
||||
bool sourcesOrHeaders)
|
||||
bool sourcesOrHeaders,
|
||||
bool listInProject)
|
||||
{
|
||||
if (files.size() == 0)
|
||||
return;
|
||||
@@ -45,6 +46,10 @@ void addCMakeVFolder(FolderNode *base,
|
||||
folder = newFolder.get();
|
||||
base->addNode(std::move(newFolder));
|
||||
}
|
||||
if (!listInProject) {
|
||||
for (auto it = files.begin(); it != files.end(); ++it)
|
||||
(*it)->setListInProject(false);
|
||||
}
|
||||
folder->addNestedNodes(std::move(files));
|
||||
folder->forEachFolderNode([] (FolderNode *fn) { fn->compress(); });
|
||||
}
|
||||
@@ -68,10 +73,7 @@ void addCMakeInputs(FolderNode *root,
|
||||
std::unique_ptr<ProjectNode> cmakeVFolder = std::make_unique<CMakeInputsNode>(root->filePath());
|
||||
|
||||
QSet<Utils::FilePath> knownFiles;
|
||||
root->forEachGenericNode([&knownFiles](const Node *n) {
|
||||
if (n->listInProject())
|
||||
knownFiles.insert(n->filePath());
|
||||
});
|
||||
root->forEachGenericNode([&knownFiles](const Node *n) { knownFiles.insert(n->filePath()); });
|
||||
|
||||
addCMakeVFolder(cmakeVFolder.get(),
|
||||
sourceDir,
|
||||
@@ -87,7 +89,9 @@ void addCMakeInputs(FolderNode *root,
|
||||
Utils::FilePath(),
|
||||
10,
|
||||
Tr::tr("<Other Locations>"),
|
||||
removeKnownNodes(knownFiles, std::move(rootInputs)));
|
||||
removeKnownNodes(knownFiles, std::move(rootInputs)),
|
||||
/*sourcesOrHeaders=*/false,
|
||||
/*listInProject=*/false);
|
||||
|
||||
root->addNode(std::move(cmakeVFolder));
|
||||
}
|
||||
|
@@ -21,7 +21,8 @@ void addCMakeVFolder(ProjectExplorer::FolderNode *base,
|
||||
int priority,
|
||||
const QString &displayName,
|
||||
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&files,
|
||||
bool sourcesOrHeaders = false);
|
||||
bool sourcesOrHeaders = false,
|
||||
bool listInProject = true);
|
||||
|
||||
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&removeKnownNodes(
|
||||
const QSet<Utils::FilePath> &knownFiles,
|
||||
|
Reference in New Issue
Block a user