summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-07-27 14:06:06 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-07-27 14:06:22 (GMT)
commit07ac0c0ae0bcd7231b6c834303531c313af28090 (patch)
tree942c2ae236a6de3db67769131c1bc93de343645e /Source/cmGlobalXCodeGenerator.cxx
parent054ed1c594e27cecee65d1681943d18ad66168f1 (diff)
parent7050ac56a11768c90f55654aa3f63d02bb549243 (diff)
downloadCMake-07ac0c0ae0bcd7231b6c834303531c313af28090.zip
CMake-07ac0c0ae0bcd7231b6c834303531c313af28090.tar.gz
CMake-07ac0c0ae0bcd7231b6c834303531c313af28090.tar.bz2
Merge topic 'xcframework-target-link-libraries'
7050ac56a1 macOS: Add support for linking against .xcframework folders 93ed53790c bootstrap: Unconditionally build libjsoncpp Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8619
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx63
1 files changed, 57 insertions, 6 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 0472631..247d4fc 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -53,6 +53,7 @@
#include "cmXCodeObject.h"
#include "cmXCodeScheme.h"
#include "cmXMLWriter.h"
+#include "cmXcFramework.h"
#include "cmake.h"
#if !defined(CMAKE_BOOTSTRAP) && defined(__APPLE__)
@@ -1061,12 +1062,14 @@ bool IsLinkPhaseLibraryExtension(const std::string& fileExt)
{
// Empty file extension is a special case for paths to framework's
// internal binary which could be MyFw.framework/Versions/*/MyFw
- return (fileExt == ".framework" || fileExt == ".a" || fileExt == ".o" ||
- fileExt == ".dylib" || fileExt == ".tbd" || fileExt.empty());
+ return (fileExt == ".framework" || fileExt == ".xcframework" ||
+ fileExt == ".a" || fileExt == ".o" || fileExt == ".dylib" ||
+ fileExt == ".tbd" || fileExt.empty());
}
bool IsLibraryType(const std::string& fileType)
{
- return (fileType == "wrapper.framework" || fileType == "archive.ar" ||
+ return (fileType == "wrapper.framework" ||
+ fileType == "wrapper.xcframework" || fileType == "archive.ar" ||
fileType == "compiled.mach-o.objfile" ||
fileType == "compiled.mach-o.dylib" ||
fileType == "compiled.mach-o.executable" ||
@@ -1079,6 +1082,9 @@ std::string GetDirectoryValueFromFileExtension(const std::string& dirExt)
if (ext == "framework") {
return "wrapper.framework";
}
+ if (ext == "xcframework") {
+ return "wrapper.xcframework";
+ }
if (ext == "xcassets") {
return "folder.assetcatalog";
}
@@ -3607,6 +3613,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
bool canUseLinkPhase = !libItem.HasFeature() ||
libItem.GetFeatureName() == "__CMAKE_LINK_FRAMEWORK"_s ||
libItem.GetFeatureName() == "FRAMEWORK"_s ||
+ libItem.GetFeatureName() == "__CMAKE_LINK_XCFRAMEWORK"_s ||
+ libItem.GetFeatureName() == "XCFRAMEWORK"_s ||
libItem.GetFeatureName() == "WEAK_FRAMEWORK"_s ||
libItem.GetFeatureName() == "WEAK_LIBRARY"_s;
if (canUseLinkPhase) {
@@ -3917,12 +3925,14 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
if (cmSystemTools::FileIsFullPath(cleanPath)) {
cleanPath = cmSystemTools::CollapseFullPath(cleanPath);
}
- bool isFramework =
+ bool isXcFramework =
+ cmHasSuffix(libName.GetFeatureName(), "XCFRAMEWORK"_s);
+ bool isFramework = !isXcFramework &&
cmHasSuffix(libName.GetFeatureName(), "FRAMEWORK"_s);
if (isFramework) {
const auto fwDescriptor = this->SplitFrameworkPath(
cleanPath, cmGlobalGenerator::FrameworkFormat::Extended);
- if (!fwDescriptor->Directory.empty() &&
+ if (isFramework && !fwDescriptor->Directory.empty() &&
emitted.insert(fwDescriptor->Directory).second) {
// This is a search path we had not added before and it isn't
// an implicit search path, so we need it
@@ -3940,13 +3950,54 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
fwDescriptor->GetLinkName()))
.Value);
}
+ } else if (isXcFramework) {
+ auto plist = cmParseXcFrameworkPlist(
+ cleanPath, *this->Makefiles.front(), libName.Value.Backtrace);
+ if (!plist) {
+ return;
+ }
+ if (auto const* library = plist->SelectSuitableLibrary(
+ *this->Makefiles.front(), libName.Value.Backtrace)) {
+ auto libraryPath =
+ cmStrCat(cleanPath, '/', library->LibraryIdentifier, '/',
+ library->LibraryPath);
+ if (auto const fwDescriptor = this->SplitFrameworkPath(
+ libraryPath,
+ cmGlobalGenerator::FrameworkFormat::Relaxed)) {
+ if (!fwDescriptor->Directory.empty() &&
+ emitted.insert(fwDescriptor->Directory).second) {
+ // This is a search path we had not added before and it
+ // isn't an implicit search path, so we need it
+ fwSearchPaths.Add(
+ this->XCodeEscapePath(fwDescriptor->Directory));
+ }
+ libPaths.Add(cmStrCat(
+ "-framework ",
+ this->XCodeEscapePath(fwDescriptor->GetLinkName())));
+ } else {
+ libPaths.Add(
+ libName.GetFormattedItem(this->XCodeEscapePath(libraryPath))
+ .Value);
+ if (!library->HeadersPath.empty()) {
+ this->AppendBuildSettingAttribute(
+ target, "HEADER_SEARCH_PATHS",
+ this->CreateString(this->XCodeEscapePath(
+ cmStrCat(cleanPath, '/', library->LibraryIdentifier, '/',
+ library->HeadersPath))),
+ configName);
+ }
+ }
+ } else {
+ return;
+ }
} else {
libPaths.Add(
libName.GetFormattedItem(this->XCodeEscapePath(cleanPath))
.Value);
}
if ((!libName.Target || libName.Target->IsImported()) &&
- (isFramework || IsLinkPhaseLibraryExtension(cleanPath))) {
+ (isFramework || isXcFramework ||
+ IsLinkPhaseLibraryExtension(cleanPath))) {
// Create file reference for embedding
auto it = this->ExternalLibRefs.find(cleanPath);
if (it == this->ExternalLibRefs.end()) {