Commit cad16c4b authored by Tobias Hunger's avatar Tobias Hunger
Browse files

CMake: Fix up file group information in server-mode

Server-mode reports a filegroup for all the listed headers and will
provide that without any information on the files (no language, include
paths, etc.).

Fix up file groups like these by using the best (with that being the
settings that effect the most other files) possible information for
these files.

CMake has no idea what headers are, so it has no way to provide any
better information, so Creator has to fix things up again:-/

Task-number: QTCREATORBUG-17971
Change-Id: Ib5ddab23cf725c7e03717b577cc9f9edc5bbfc61
Reviewed-by: Tim Jenssen's avatarTim Jenssen <>
parent ff46e679
......@@ -470,6 +470,8 @@ ServerModeReader::Target *ServerModeReader::extractTargetData(const QVariantMap
target->fileGroups.append(extractFileGroupData(fgData, srcDir, target));
return target;
......@@ -548,6 +550,49 @@ void ServerModeReader::extractCacheData(const QVariantMap &data)
m_cmakeCache = config;
void ServerModeReader::fixTarget(ServerModeReader::Target *target) const
QHash<QString, const FileGroup *> languageFallbacks;
for (const FileGroup *group : Utils::asConst(target->fileGroups)) {
if (group->includePaths.isEmpty() && group->compileFlags.isEmpty()
&& group->defines.isEmpty())
const FileGroup *fallback = languageFallbacks.value(group->language);
if (!fallback || fallback->sources.count() < group->sources.count())
languageFallbacks.insert(group->language, group);
if (!languageFallbacks.value(""))
return; // No empty language groups found, no need to proceed.
const FileGroup *fallback = languageFallbacks.value("CXX");
if (!fallback)
fallback = languageFallbacks.value("C");
if (!fallback)
fallback = languageFallbacks.value("");
if (!fallback)
for (auto it = target->fileGroups.begin(); it != target->fileGroups.end(); ++it) {
if (!(*it)->language.isEmpty())
(*it)->language = fallback->language.isEmpty() ? "CXX" : fallback->language;
if (*it == fallback
|| !(*it)->includePaths.isEmpty() || !(*it)->defines.isEmpty()
|| !(*it)->compileFlags.isEmpty())
for (const IncludePath *ip : fallback->includePaths)
(*it)->includePaths.append(new IncludePath(*ip));
(*it)->defines = fallback->defines;
(*it)->compileFlags = fallback->compileFlags;
QHash<Utils::FileName, ProjectNode *>
ServerModeReader::addCMakeLists(CMakeProjectNode *root, const QList<FileNode *> &cmakeLists)
......@@ -113,6 +113,8 @@ private:
void extractCMakeInputsData(const QVariantMap &data);
void extractCacheData(const QVariantMap &data);
void fixTarget(Target *target) const;
QHash<Utils::FileName, ProjectExplorer::ProjectNode *>
addCMakeLists(CMakeProjectNode *root, const QList<ProjectExplorer::FileNode *> &cmakeLists);
void addProjects(const QHash<Utils::FileName, ProjectExplorer::ProjectNode *> &cmakeListsNodes,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment