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 <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2018-01-26 11:24:56 +01:00
parent 4ba4079db2
commit 9b495853c6

View File

@@ -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<FileNode *> toList;
QSet<Utils::FileName> alreadyListed;
// Files already added by other configurations:
targetRoot->forEachGenericNode([&alreadyListed](const Node *n) {
alreadyListed.insert(n->filePath());
});
for (const FileGroup *f : fileGroups) {
const QList<FileName> newSources = Utils::filtered(f->sources, [&alreadyListed](const Utils::FileName &fn) {
const int count = alreadyListed.count();