From ce1bdec3a4f5fb10a1bd6df3ab0ca469c2f8a22d Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sun, 5 Mar 2023 14:36:43 +0100 Subject: Xcode: Fix missing Frameworks search paths Fixes: #24541 --- Source/cmComputeLinkInformation.cxx | 32 +++++++++++++--------- .../RunCMake/Framework/FrameworkConsumption.cmake | 10 +++++-- Tests/RunCMake/Framework/consumer.c | 9 ++++++ 3 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 Tests/RunCMake/Framework/consumer.c diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 78508f3..a93477b 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1563,7 +1563,7 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) this->OldLinkDirItems.push_back(item.Value); } - if (target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) { + if (target->IsFrameworkOnApple()) { // Add the framework directory and the framework item itself auto fwDescriptor = this->GlobalGenerator->SplitFrameworkPath( item.Value, cmGlobalGenerator::FrameworkFormat::Extended); @@ -1579,26 +1579,32 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) // Add the directory portion to the framework search path. this->AddFrameworkPath(fwDescriptor->Directory); } - if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s)) { - this->Items.emplace_back(fwDescriptor->GetLinkName(), ItemIsPath::Yes, - target, - this->FindLibraryFeature(entry.Feature)); - } else { + + if (this->GlobalGenerator->IsXcode()) { this->Items.emplace_back( item, ItemIsPath::Yes, target, - this->FindLibraryFeature( - entry.Feature == DEFAULT ? "__CMAKE_LINK_LIBRARY" : entry.Feature)); + this->FindLibraryFeature(entry.Feature == DEFAULT + ? "__CMAKE_LINK_FRAMEWORK" + : entry.Feature)); + } else { + if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s)) { + this->Items.emplace_back(fwDescriptor->GetLinkName(), ItemIsPath::Yes, + target, + this->FindLibraryFeature(entry.Feature)); + } else { + this->Items.emplace_back( + item, ItemIsPath::Yes, target, + this->FindLibraryFeature(entry.Feature == DEFAULT + ? "__CMAKE_LINK_LIBRARY" + : entry.Feature)); + } } } else { // Now add the full path to the library. this->Items.emplace_back( item, ItemIsPath::Yes, target, this->FindLibraryFeature( - entry.Feature == DEFAULT - ? (target->IsFrameworkOnApple() && this->GlobalGenerator->IsXcode() - ? "__CMAKE_LINK_FRAMEWORK" - : "__CMAKE_LINK_LIBRARY") - : entry.Feature)); + entry.Feature == DEFAULT ? "__CMAKE_LINK_LIBRARY" : entry.Feature)); } } diff --git a/Tests/RunCMake/Framework/FrameworkConsumption.cmake b/Tests/RunCMake/Framework/FrameworkConsumption.cmake index a1ce006..2180cf9 100644 --- a/Tests/RunCMake/Framework/FrameworkConsumption.cmake +++ b/Tests/RunCMake/Framework/FrameworkConsumption.cmake @@ -22,10 +22,14 @@ set_target_properties(Gui2 PROPERTIES ) add_executable(app2 main2.c) -set_target_properties(Gui2 PROPERTIES - PUBLIC_HEADER "${input_header}" - FRAMEWORK TRUE +set_target_properties(app2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY bin ) target_link_libraries(app2 PRIVATE Gui2) + + +# Same test with STATIC consumer +add_library(Consumer STATIC consumer.c) + +target_link_libraries(Consumer PRIVATE Gui2) diff --git a/Tests/RunCMake/Framework/consumer.c b/Tests/RunCMake/Framework/consumer.c new file mode 100644 index 0000000..a578976 --- /dev/null +++ b/Tests/RunCMake/Framework/consumer.c @@ -0,0 +1,9 @@ + +#include + +int consumer() +{ + foo(); + + return 0; +} -- cgit v0.12