forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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(); });
|
||||
|
||||
Reference in New Issue
Block a user