summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-09-14 16:52:10 (GMT)
committerBrad King <brad.king@kitware.com>2022-09-14 18:55:27 (GMT)
commitfc06450ff49db8ebf86977b85206c75de4a40ed3 (patch)
tree0290d6bc1528c72a1496a7589e3df3820e7cad4b
parent31f835410efeea50acd43512eb9e5646a26ea177 (diff)
downloadCMake-fc06450ff49db8ebf86977b85206c75de4a40ed3.zip
CMake-fc06450ff49db8ebf86977b85206c75de4a40ed3.tar.gz
CMake-fc06450ff49db8ebf86977b85206c75de4a40ed3.tar.bz2
Apple: Fix regression when linking a framework with postfix
Fix a regression caused by commit 40178f3c90 (cmGlobalGenerator: Add helper to split framework path, 2022-02-10, v3.24.0-rc1~661^2~1). Fixes: #23961
-rw-r--r--Source/cmComputeLinkInformation.cxx12
-rw-r--r--Source/cmGlobalGenerator.cxx3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx14
-rw-r--r--Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake5
4 files changed, 23 insertions, 11 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 850b7a3..cda70fc 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -368,6 +368,10 @@ cmComputeLinkInformation::cmComputeLinkInformation(
LibraryFeatureDescriptor{ "__CMAKE_LINK_EXECUTABLE",
cmStrCat(this->LoaderFlag, "<LIBRARY>") });
}
+ // To link framewortk using a full path
+ this->LibraryFeatureDescriptors.emplace(
+ "__CMAKE_LINK_FRAMEWORK",
+ LibraryFeatureDescriptor{ "__CMAKE_LINK_FRAMEWORK", "<LIBRARY>" });
// Check the platform policy for missing soname case.
this->NoSONameUsesPath =
@@ -1560,12 +1564,6 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
this->OldLinkDirItems.push_back(item.Value);
}
- if (target->IsFrameworkOnApple() && this->GlobalGenerator->IsXcode() &&
- entry.Feature == DEFAULT) {
- // ensure FRAMEWORK feature is loaded
- this->AddLibraryFeature("FRAMEWORK");
- }
-
if (target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) {
// Add the framework directory and the framework item itself
auto fwItems = this->GlobalGenerator->SplitFrameworkPath(item.Value, true);
@@ -1597,7 +1595,7 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
this->FindLibraryFeature(
entry.Feature == DEFAULT
? (target->IsFrameworkOnApple() && this->GlobalGenerator->IsXcode()
- ? "FRAMEWORK"
+ ? "__CMAKE_LINK_FRAMEWORK"
: "__CMAKE_LINK_LIBRARY")
: entry.Feature));
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 254220b..0fe55f0 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -50,6 +50,7 @@
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmValue.h"
#include "cmVersion.h"
@@ -2570,7 +2571,7 @@ cmGlobalGenerator::SplitFrameworkPath(const std::string& path,
auto name = frameworkPath.match(3);
auto libname =
cmSystemTools::GetFilenameWithoutExtension(frameworkPath.match(6));
- if (!libname.empty() && name != libname) {
+ if (!libname.empty() && !cmHasPrefix(libname, name)) {
return cm::nullopt;
}
return std::pair<std::string, std::string>{ frameworkPath.match(2), name };
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index b9bbb67..433edaf 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3813,9 +3813,17 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
// an implicit search path, so we need it
libPaths.Add("-F " + this->XCodeEscapePath(fwItems->first));
}
- libPaths.Add(
- libName.GetFormattedItem(this->XCodeEscapePath(fwItems->second))
- .Value);
+ if (libName.GetFeatureName() == "__CMAKE_LINK_FRAMEWORK"_s) {
+ // use the full path
+ libPaths.Add(
+ libName.GetFormattedItem(this->XCodeEscapePath(cleanPath))
+ .Value);
+ } else {
+ libPaths.Add(
+ libName
+ .GetFormattedItem(this->XCodeEscapePath(fwItems->second))
+ .Value);
+ }
} else {
libPaths.Add(
libName.GetFormattedItem(this->XCodeEscapePath(cleanPath))
diff --git a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake
index 51e627d..3afda4d 100644
--- a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake
+++ b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake
@@ -23,3 +23,8 @@ string(APPEND content
"set(target_file_name ${target_name})\n")
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkMultiConfigPostfixInfo.cmake
CONTENT "${content}")
+
+
+# Try to link this framework to ensure postfix is correctly handled
+add_library(otherlib SHARED foo.c)
+target_link_libraries(otherlib PRIVATE ${target_name})