forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -486,6 +486,26 @@ static std::vector<FileApiDetails::FragmentInfo> extractFragments(const QJsonObj
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void addIncludeInfo(std::vector<IncludeInfo> *includes,
|
||||||
|
const QJsonObject &compileGroups,
|
||||||
|
const QString §ion)
|
||||||
|
{
|
||||||
|
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)
|
static TargetDetails extractTargetDetails(const QJsonObject &root, QString &errorMessage)
|
||||||
{
|
{
|
||||||
TargetDetails t;
|
TargetDetails t;
|
||||||
@@ -581,6 +601,10 @@ static TargetDetails extractTargetDetails(const QJsonObject &root, QString &erro
|
|||||||
const QJsonArray compileGroups = root.value("compileGroups").toArray();
|
const QJsonArray compileGroups = root.value("compileGroups").toArray();
|
||||||
t.compileGroups = transform<std::vector>(compileGroups, [](const QJsonValue &v) {
|
t.compileGroups = transform<std::vector>(compileGroups, [](const QJsonValue &v) {
|
||||||
const QJsonObject o = v.toObject();
|
const QJsonObject o = v.toObject();
|
||||||
|
std::vector<IncludeInfo> includes;
|
||||||
|
addIncludeInfo(&includes, o, "includes");
|
||||||
|
// new in CMake 3.27+:
|
||||||
|
addIncludeInfo(&includes, o, "frameworks");
|
||||||
return CompileInfo{
|
return CompileInfo{
|
||||||
transform<std::vector>(o.value("sourceIndexes").toArray(),
|
transform<std::vector>(o.value("sourceIndexes").toArray(),
|
||||||
[](const QJsonValue &v) { return v.toInt(-1); }),
|
[](const QJsonValue &v) { return v.toInt(-1); }),
|
||||||
@@ -590,21 +614,7 @@ static TargetDetails extractTargetDetails(const QJsonObject &root, QString &erro
|
|||||||
const QJsonObject o = v.toObject();
|
const QJsonObject o = v.toObject();
|
||||||
return o.value("fragment").toString();
|
return o.value("fragment").toString();
|
||||||
}),
|
}),
|
||||||
transform<std::vector>(
|
includes,
|
||||||
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)};
|
|
||||||
}),
|
|
||||||
transform<std::vector>(o.value("defines").toArray(),
|
transform<std::vector>(o.value("defines").toArray(),
|
||||||
[](const QJsonValue &v) {
|
[](const QJsonValue &v) {
|
||||||
const QJsonObject d = v.toObject();
|
const QJsonObject d = v.toObject();
|
||||||
|
Reference in New Issue
Block a user