diff --git a/plugins/cmake/cmakeprojectdata.h b/plugins/cmake/cmakeprojectdata.h --- a/plugins/cmake/cmakeprojectdata.h +++ b/plugins/cmake/cmakeprojectdata.h @@ -41,6 +41,12 @@ KDevelop::Path::List frameworkDirectories; QString compileFlags; QHash defines; + + bool isEmpty() const + { + return includes.isEmpty() && frameworkDirectories.isEmpty() + && compileFlags.isEmpty() && defines.isEmpty(); + } }; inline QDebug &operator<<(QDebug debug, const CMakeFile& file) { diff --git a/plugins/cmake/cmakeserverimportjob.cpp b/plugins/cmake/cmakeserverimportjob.cpp --- a/plugins/cmake/cmakeserverimportjob.cpp +++ b/plugins/cmake/cmakeserverimportjob.cpp @@ -118,6 +118,13 @@ file.compileFlags = fileGroup.value(QStringLiteral("compileFlags")).toString(); file.defines = processDefines(file.compileFlags, fileGroup.value(QStringLiteral("defines")).toArray()); + // apparently some file groups do not contain build system information + // skip these, as they would produce bogus results for us and break the fallback + // implemented in CMakeManager::fileInformation + if (file.isEmpty()) { + continue; + } + const auto sourcesArray = fileGroup.value(QStringLiteral("sources")).toArray(); const KDevelop::Path::List sources = kTransform(sourcesArray, [targetDir](const QJsonValue& val) { return KDevelop::Path(targetDir, val.toString()); }); targetSources.reserve(targetSources.size() + sources.size());