From a7cbae1e4ddb9744d4448b5478827630356717d8 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 16 Aug 2016 17:31:26 +0200 Subject: [PATCH] CMake: Make sure top level CMakeLists.txt file is listed exactly once The toplevel CMakeLists.txt file should always be visible in the project tree, otherwise there is no way to fix problems that stop creator from reading the project structure. Since the cmake configuration may add that file itself, creator needs to check before adding that file. All other files are taken straight from cmake, which makes sure they are unique. See the minimal project attached to QTCREATORBUG-16671 for an example triggering this issue. Change-Id: Iff3e307134b023e6955f47657e998a5981b03da0 Reviewed-by: Eike Ziller --- src/plugins/cmakeprojectmanager/builddirmanager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/builddirmanager.cpp b/src/plugins/cmakeprojectmanager/builddirmanager.cpp index 1064d308243..28cbac588c8 100644 --- a/src/plugins/cmakeprojectmanager/builddirmanager.cpp +++ b/src/plugins/cmakeprojectmanager/builddirmanager.cpp @@ -382,7 +382,10 @@ void BuildDirManager::extractData() m_files.append(cbpparser.cmakeFileList()); foreach (const ProjectExplorer::FileNode *node, cbpparser.cmakeFileList()) m_cmakeFiles.insert(node->filePath()); - } else { + } + + // Make sure the top cmakelists.txt file is always listed: + if (!Utils::contains(m_files, [topCMake](ProjectExplorer::FileNode *fn) { return fn->filePath() == topCMake; })) { m_files.append(new ProjectExplorer::FileNode(topCMake, ProjectExplorer::ProjectFileType, false)); }