diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2018-11-16 14:10:35 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2018-11-19 09:44:51 +0000 |
commit | 152d2245d9ed10aad188208cbdea02f0cf94c482 (patch) | |
tree | 930dbeb19967982b3c919ecc815bc6a66fb197b9 /src/plugins/cmakeprojectmanager/servermodereader.cpp | |
parent | 96e300c0e6aae8685abeb266e04b0fb318e1edff (diff) | |
download | qt-creator-152d2245d9ed10aad188208cbdea02f0cf94c482.tar.gz |
CMake: Suppress header-only targets from code model
Do not report targets that contain headers only and have no
include directories/defines set up to the code model. Such targets
are used to tell creator about the projects header files as a
work-around to creator not reporting headers in cmake projects.
This work-around is of course not necessary anymore, but it is widely
used and breaks the heuristics in the code model. So do not inform
the code model about these parts of the project.
Task-number: QTCREATORBUG-21425
Change-Id: I387d9d9fb4ae7b54fa08ee9b23efb9ab1f179b9c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/servermodereader.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/servermodereader.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/cmakeprojectmanager/servermodereader.cpp b/src/plugins/cmakeprojectmanager/servermodereader.cpp index 3451e704da..54364f75c7 100644 --- a/src/plugins/cmakeprojectmanager/servermodereader.cpp +++ b/src/plugins/cmakeprojectmanager/servermodereader.cpp @@ -360,6 +360,19 @@ void ServerModeReader::updateCodeModel(CppTools::RawProjectParts &rpps) { int counter = 0; for (const FileGroup *fg : qAsConst(m_fileGroups)) { + // CMake users worked around Creator's inability of listing header files by creating + // custom targets with all the header files. This target breaks the code model, so + // keep quiet about it:-) + if (fg->macros.isEmpty() + && fg->includePaths.isEmpty() + && !fg->isGenerated + && Utils::allOf(fg->sources, [](const Utils::FileName &source) { + return Node::fileTypeForFileName(source) == FileType::Header; + })) { + qWarning() << "Not reporting all-header file group of target" << fg->target << "to code model."; + continue; + } + ++counter; const QStringList flags = QtcProcess::splitArgs(fg->compileFlags); const QStringList includes = transform(fg->includePaths, [](const IncludePath *ip) { return ip->path.toString(); }); |