From b1c0ecb4a53e7ccf46ba3c5941d51375c9da60cd Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 25 Feb 2019 12:31:17 +0100 Subject: [PATCH] CMakeProjectManager: Do not mark source-tree CMakeLists.txt as generated This is what the code according to the comment tried to do. Change-Id: Id585660fedec2c4eacce556ef25caa8479206c5c Reviewed-by: Tobias Hunger Reviewed-by: hjk --- .../cmakeprojectmanager/servermodereader.cpp | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/servermodereader.cpp b/src/plugins/cmakeprojectmanager/servermodereader.cpp index 2578f8a7595..baa7a776dc2 100644 --- a/src/plugins/cmakeprojectmanager/servermodereader.cpp +++ b/src/plugins/cmakeprojectmanager/servermodereader.cpp @@ -691,19 +691,28 @@ void ServerModeReader::extractCMakeInputsData(const QVariantMap &data) const QVariantMap §ion = bf.toMap(); const QStringList sources = section.value(SOURCES_KEY).toStringList(); - const bool isTemporary = section.value("isTemporary").toBool(); - const bool isCMake = section.value("isCMake").toBool(); + const bool isTemporary = section.value("isTemporary").toBool(); // generated file + const bool isCMake = section.value("isCMake").toBool(); // part of the cmake installation for (const QString &s : sources) { const FileName sfn = FileName::fromString(QDir::cleanPath(srcDir.absoluteFilePath(s))); const int oldCount = m_cmakeFiles.count(); m_cmakeFiles.insert(sfn); - if (oldCount < m_cmakeFiles.count() && (!isCMake || sfn.toString().endsWith("/CMakeLists.txt"))) { - // Always include CMakeLists.txt files, even when cmake things these are part of its - // stuff. This unbreaks cmake binaries running from their own build directory. - m_cmakeInputsFileNodes.emplace_back( - std::make_unique(sfn, FileType::Project)); - m_cmakeInputsFileNodes.back()->setIsGenerated(isTemporary); + if (oldCount < m_cmakeFiles.count()) { + const bool isCMakeListsFile = sfn.toString().endsWith("/CMakeLists.txt"); + + if (isCMake && !isCMakeListsFile) + // Skip files that cmake considers to be part of the installation -- but include + // CMakeLists.txt files. This unbreaks cmake binaries running from their own + // build directory. + continue; + + auto node = std::make_unique(sfn, FileType::Project); + node->setIsGenerated(isTemporary && !isCMakeListsFile); // CMakeLists.txt are never + // generated, independent + // what cmake thinks:-) + + m_cmakeInputsFileNodes.emplace_back(std::move(node)); } } }