aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2023-08-01 17:40:20 +0200
committerEike Ziller <eike.ziller@qt.io>2023-08-02 05:55:24 +0000
commitc4089a699ee30916112ad8037529d6c7f59a809d (patch)
treed1d3a8eb2cee7ceb873bac124452d6761d32a16c
parent34bc3030ecea41f98575a2f259c7ae770528b860 (diff)
CMake/macOS: Fix framework paths with CMake >= 3.27
Previously the "compileGroups" > "includes" section contained paths to frameworks, like "<Qt>/lib/QtCore.framework" which we use to add a framework path of "<Qt>/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 <cristian.adam@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r--src/plugins/cmakeprojectmanager/fileapiparser.cpp40
1 files 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<FileApiDetails::FragmentInfo> extractFragments(const QJsonObj
});
}
+static void addIncludeInfo(std::vector<IncludeInfo> *includes,
+ const QJsonObject &compileGroups,
+ const QString &section)
+{
+ const std::vector<IncludeInfo> add
+ = transform<std::vector>(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<std::vector>(compileGroups, [](const QJsonValue &v) {
const QJsonObject o = v.toObject();
+ std::vector<IncludeInfo> includes;
+ addIncludeInfo(&includes, o, "includes");
+ // new in CMake 3.27+:
+ addIncludeInfo(&includes, o, "frameworks");
return CompileInfo{
transform<std::vector>(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<std::vector>(
- 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<std::vector>(o.value("defines").toArray(),
[](const QJsonValue &v) {
const QJsonObject d = v.toObject();