mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 21:00:17 -06:00
Merge topic 'link-framework-with-multi-config-postfix'
fc06450ff4 Apple: Fix regression when linking a framework with postfix
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7675
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
@@ -2579,7 +2580,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 };
|
||||
|
||||
@@ -3841,9 +3841,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))
|
||||
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user