summaryrefslogtreecommitdiffstats
path: root/Source/cmComputeLinkInformation.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmComputeLinkInformation.cxx')
-rw-r--r--Source/cmComputeLinkInformation.cxx88
1 files changed, 88 insertions, 0 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index a50ce11..be73fa3 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -29,6 +29,7 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmValue.h"
+#include "cmXcFramework.h"
#include "cmake.h"
// #define CM_COMPUTE_LINK_INFO_DEBUG
@@ -373,6 +374,10 @@ cmComputeLinkInformation::cmComputeLinkInformation(
this->LibraryFeatureDescriptors.emplace(
"__CMAKE_LINK_FRAMEWORK",
LibraryFeatureDescriptor{ "__CMAKE_LINK_FRAMEWORK", "<LIBRARY>" });
+ // To link xcframework using a full path
+ this->LibraryFeatureDescriptors.emplace(
+ "__CMAKE_LINK_XCFRAMEWORK",
+ LibraryFeatureDescriptor{ "__CMAKE_LINK_XCFRAMEWORK", "<LIBRARY>" });
// Check the platform policy for missing soname case.
this->NoSONameUsesPath =
@@ -519,6 +524,12 @@ cmComputeLinkInformation::GetFrameworkPathsEmitted() const
return this->FrameworkPathsEmitted;
}
+std::vector<std::string> const&
+cmComputeLinkInformation::GetXcFrameworkHeaderPaths() const
+{
+ return this->XcFrameworkHeaderPaths;
+}
+
const std::set<const cmGeneratorTarget*>&
cmComputeLinkInformation::GetSharedLibrariesLinked() const
{
@@ -1159,6 +1170,13 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
} else {
this->ObjectLibrariesLinked.push_back(entry.Target);
}
+ } else if (this->GlobalGenerator->IsXcode() &&
+ !tgt->GetImportedXcFrameworkPath(config).empty()) {
+ this->Items.emplace_back(
+ tgt->GetImportedXcFrameworkPath(config), ItemIsPath::Yes, tgt,
+ this->FindLibraryFeature(entry.Feature == DEFAULT
+ ? "__CMAKE_LINK_XCFRAMEWORK"
+ : entry.Feature));
} else {
// Decide whether to use an import library.
cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(config)
@@ -1198,6 +1216,25 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
this->AddRuntimeDLL(tgt);
}
}
+
+ auto xcFrameworkPath = tgt->GetImportedXcFrameworkPath(config);
+ if (!xcFrameworkPath.empty()) {
+ auto plist = cmParseXcFrameworkPlist(xcFrameworkPath, *this->Makefile,
+ item.Backtrace);
+ if (!plist) {
+ return;
+ }
+ if (auto const* library =
+ plist->SelectSuitableLibrary(*this->Makefile, item.Backtrace)) {
+ if (!library->HeadersPath.empty()) {
+ this->AddXcFrameworkHeaderPath(cmStrCat(xcFrameworkPath, '/',
+ library->LibraryIdentifier,
+ '/', library->HeadersPath));
+ }
+ } else {
+ return;
+ }
+ }
} else {
// This is not a CMake target. Use the name given.
if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s) ||
@@ -1206,6 +1243,12 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
this->Target->IsApple())) {
// This is a framework.
this->AddFrameworkItem(entry);
+ } else if (cmHasSuffix(entry.Feature, "XCFRAMEWORK"_s) ||
+ (entry.Feature == DEFAULT &&
+ cmSystemTools::IsPathToXcFramework(item.Value) &&
+ this->Target->IsApple())) {
+ // This is a framework.
+ this->AddXcFrameworkItem(entry);
} else if (cmSystemTools::FileIsFullPath(item.Value)) {
if (cmSystemTools::FileIsDirectory(item.Value)) {
// This is a directory.
@@ -1945,6 +1988,46 @@ void cmComputeLinkInformation::AddFrameworkItem(LinkEntry const& entry)
}
}
+void cmComputeLinkInformation::AddXcFrameworkItem(LinkEntry const& entry)
+{
+ auto plist = cmParseXcFrameworkPlist(entry.Item.Value, *this->Makefile,
+ entry.Item.Backtrace);
+ if (!plist) {
+ return;
+ }
+
+ if (auto const* lib =
+ plist->SelectSuitableLibrary(*this->Makefile, entry.Item.Backtrace)) {
+ if (this->GlobalGenerator->IsXcode()) {
+ this->Items.emplace_back(
+ entry.Item.Value, ItemIsPath::Yes, nullptr,
+ this->FindLibraryFeature(entry.Feature == DEFAULT
+ ? "__CMAKE_LINK_XCFRAMEWORK"
+ : entry.Feature));
+ } else {
+ auto libraryPath = cmStrCat(
+ entry.Item.Value, '/', lib->LibraryIdentifier, '/', lib->LibraryPath);
+ LinkEntry libraryEntry(
+ BT<std::string>(libraryPath, entry.Item.Backtrace), entry.Target);
+
+ if (cmSystemTools::IsPathToFramework(libraryPath) &&
+ this->Target->IsApple()) {
+ // This is a framework.
+ this->AddFrameworkItem(libraryEntry);
+ } else {
+ this->Depends.push_back(libraryPath);
+ this->AddFullItem(libraryEntry);
+ this->AddLibraryRuntimeInfo(libraryPath);
+ if (!lib->HeadersPath.empty()) {
+ this->AddXcFrameworkHeaderPath(cmStrCat(entry.Item.Value, '/',
+ lib->LibraryIdentifier, '/',
+ lib->HeadersPath));
+ }
+ }
+ }
+ }
+}
+
void cmComputeLinkInformation::DropDirectoryItem(BT<std::string> const& item)
{
// A full path to a directory was found as a link item. Warn the
@@ -1982,6 +2065,11 @@ void cmComputeLinkInformation::AddFrameworkPath(std::string const& p)
}
}
+void cmComputeLinkInformation::AddXcFrameworkHeaderPath(std::string const& p)
+{
+ this->XcFrameworkHeaderPaths.push_back(p);
+}
+
bool cmComputeLinkInformation::CheckSharedLibNoSOName(LinkEntry const& entry)
{
// This platform will use the path to a library as its soname if the