From c4089a699ee30916112ad8037529d6c7f59a809d Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 1 Aug 2023 17:40:20 +0200 Subject: CMake/macOS: Fix framework paths with CMake >= 3.27 Previously the "compileGroups" > "includes" section contained paths to frameworks, like "/lib/QtCore.framework" which we use to add a framework path of "/lib" to the code model. These paths moved to a new "compileGroups" > "frameworks" section in file-api in CMake >= 3.27, so we need to read this section as well. Fixes: QTCREATORBUG-29450 Change-Id: Ica685006d1373fdc3efee6029acf4a7f7e8528f3 Reviewed-by: Cristian Adam Reviewed-by: --- src/plugins/cmakeprojectmanager/fileapiparser.cpp | 40 ++++++++++++++--------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/fileapiparser.cpp b/src/plugins/cmakeprojectmanager/fileapiparser.cpp index e4dca5c9b2..2e63a56cee 100644 --- a/src/plugins/cmakeprojectmanager/fileapiparser.cpp +++ b/src/plugins/cmakeprojectmanager/fileapiparser.cpp @@ -486,6 +486,26 @@ static std::vector extractFragments(const QJsonObj }); } +static void addIncludeInfo(std::vector *includes, + const QJsonObject &compileGroups, + const QString §ion) +{ + const std::vector add + = transform(compileGroups.value(section).toArray(), [](const QJsonValue &v) { + const QJsonObject i = v.toObject(); + const QString path = i.value("path").toString(); + const bool isSystem = i.value("isSystem").toBool(); + const ProjectExplorer::HeaderPath hp(path, + isSystem + ? ProjectExplorer::HeaderPathType::System + : ProjectExplorer::HeaderPathType::User); + + return IncludeInfo{ProjectExplorer::RawProjectPart::frameworkDetectionHeuristic(hp), + i.value("backtrace").toInt(-1)}; + }); + std::copy(add.cbegin(), add.cend(), std::back_inserter(*includes)); +} + static TargetDetails extractTargetDetails(const QJsonObject &root, QString &errorMessage) { TargetDetails t; @@ -581,6 +601,10 @@ static TargetDetails extractTargetDetails(const QJsonObject &root, QString &erro const QJsonArray compileGroups = root.value("compileGroups").toArray(); t.compileGroups = transform(compileGroups, [](const QJsonValue &v) { const QJsonObject o = v.toObject(); + std::vector includes; + addIncludeInfo(&includes, o, "includes"); + // new in CMake 3.27+: + addIncludeInfo(&includes, o, "frameworks"); return CompileInfo{ transform(o.value("sourceIndexes").toArray(), [](const QJsonValue &v) { return v.toInt(-1); }), @@ -590,21 +614,7 @@ static TargetDetails extractTargetDetails(const QJsonObject &root, QString &erro const QJsonObject o = v.toObject(); return o.value("fragment").toString(); }), - transform( - o.value("includes").toArray(), - [](const QJsonValue &v) { - const QJsonObject i = v.toObject(); - const QString path = i.value("path").toString(); - const bool isSystem = i.value("isSystem").toBool(); - const ProjectExplorer::HeaderPath - hp(path, - isSystem ? ProjectExplorer::HeaderPathType::System - : ProjectExplorer::HeaderPathType::User); - - return IncludeInfo{ - ProjectExplorer::RawProjectPart::frameworkDetectionHeuristic(hp), - i.value("backtrace").toInt(-1)}; - }), + includes, transform(o.value("defines").toArray(), [](const QJsonValue &v) { const QJsonObject d = v.toObject(); -- cgit v1.2.3