From 4aa86da82798ed5d741e0204ce3c9f59aa697956 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Thu, 13 Oct 2022 17:20:38 +0200 Subject: Xcode: ensure framework with custom output directory can be consumed Fixes: #24046 --- Source/cmGlobalXCodeGenerator.cxx | 18 +++++++++++++----- Tests/RunCMake/Framework/FrameworkConsumption.cmake | 18 ++++++++++++++++++ Tests/RunCMake/Framework/main2.c | 9 +++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 Tests/RunCMake/Framework/main2.c diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6b867d4..a1af268 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3830,6 +3830,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) const auto& fwPaths = cli->GetFrameworkPaths(); emitted.insert(fwPaths.begin(), fwPaths.end()); BuildObjectListOrString libPaths(this, true); + BuildObjectListOrString fwSearchPaths(this, true); for (auto const& libItem : configItemMap[configName]) { auto const& libName = *libItem; if (libName.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) { @@ -3846,8 +3847,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) 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 - libPaths.Add("-F " + - this->XCodeEscapePath(fwDescriptor->Directory)); + fwSearchPaths.Add( + this->XCodeEscapePath(fwDescriptor->Directory)); } if (libName.GetFeatureName() == "__CMAKE_LINK_FRAMEWORK"_s) { // use the full path @@ -3886,9 +3887,16 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) target->AddDependTarget(configName, libName.Target->GetName()); } } - this->AppendBuildSettingAttribute(target, - this->GetTargetLinkFlagsVar(gt), - libPaths.CreateList(), configName); + if (!libPaths.IsEmpty()) { + this->AppendBuildSettingAttribute(target, + this->GetTargetLinkFlagsVar(gt), + libPaths.CreateList(), configName); + } + if (!fwSearchPaths.IsEmpty()) { + this->AppendBuildSettingAttribute(target, "FRAMEWORK_SEARCH_PATHS", + fwSearchPaths.CreateList(), + configName); + } } } } diff --git a/Tests/RunCMake/Framework/FrameworkConsumption.cmake b/Tests/RunCMake/Framework/FrameworkConsumption.cmake index 4663166..58b70a3 100644 --- a/Tests/RunCMake/Framework/FrameworkConsumption.cmake +++ b/Tests/RunCMake/Framework/FrameworkConsumption.cmake @@ -13,3 +13,21 @@ set_target_properties(Gui PROPERTIES add_executable(app main.c) target_link_libraries(app PRIVATE Gui) + + +# Same test but with generation done in custom directories +add_library(Gui2 SHARED Gui.c "${input_header}") +set_target_properties(Gui2 PROPERTIES + PUBLIC_HEADER "${input_header}" + FRAMEWORK TRUE + LIBRARY_OUTPUT_DIRECTORY lib +) + +add_executable(app2 main2.c) +set_target_properties(Gui2 PROPERTIES + PUBLIC_HEADER "${input_header}" + FRAMEWORK TRUE + RUNTIME_OUTPUT_DIRECTORY bin +) + +target_link_libraries(app2 PRIVATE Gui2) diff --git a/Tests/RunCMake/Framework/main2.c b/Tests/RunCMake/Framework/main2.c new file mode 100644 index 0000000..11f4e4d --- /dev/null +++ b/Tests/RunCMake/Framework/main2.c @@ -0,0 +1,9 @@ + +#include + +int main() +{ + foo(); + + return 0; +} -- cgit v0.12