From 9b495853c663c3efac4b8c3c440b4a9ab70f6999 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 26 Jan 2018 11:24:56 +0100 Subject: [PATCH] CMake: Ignore duplicate files in server-mode Some cmake generators create a set of different configurations of the project at the same time (e.g. Visual Studio related ones). These typically contain the same set of files. Creator iterates over the configurations and adds files to the project tree. For multi-configuration generators this does lead to the same file being listed several times below a target (the targets themselves were already deduplicated!). This patch adds deduplication of file paths already listed in the target's subtree of the project, thus fixing the multiple files issue. New files (e.g. those that get only built in debug/release mode) will still get added as before. Task-number: QTCREATORBUG-19020 Change-Id: I5dd6012ea335d9946c78c25be258c8c4d60698f2 Reviewed-by: hjk --- src/plugins/cmakeprojectmanager/servermodereader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/servermodereader.cpp b/src/plugins/cmakeprojectmanager/servermodereader.cpp index f4a6235e767..20817562751 100644 --- a/src/plugins/cmakeprojectmanager/servermodereader.cpp +++ b/src/plugins/cmakeprojectmanager/servermodereader.cpp @@ -460,7 +460,6 @@ int ServerModeReader::calculateProgress(const int minRange, const int min, const void ServerModeReader::extractCodeModelData(const QVariantMap &data) { const QVariantList configs = data.value("configurations").toList(); - QTC_CHECK(configs.count() == 1); // FIXME: Support several configurations! for (const QVariant &c : configs) { const QVariantMap &cData = c.toMap(); extractConfigurationData(cData); @@ -842,6 +841,11 @@ void ServerModeReader::addFileGroups(ProjectNode *targetRoot, { QList toList; QSet alreadyListed; + // Files already added by other configurations: + targetRoot->forEachGenericNode([&alreadyListed](const Node *n) { + alreadyListed.insert(n->filePath()); + }); + for (const FileGroup *f : fileGroups) { const QList newSources = Utils::filtered(f->sources, [&alreadyListed](const Utils::FileName &fn) { const int count = alreadyListed.count();