mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 23:28:32 -05:00
Ensure targets which are frameworks can be used freely
Ensure flag -F/path/to/framework is specified during compilation step of consumers of the framework. Fixes: #23336
This commit is contained in:
@@ -1555,8 +1555,7 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
|
|||||||
this->AddLibraryFeature("FRAMEWORK");
|
this->AddLibraryFeature("FRAMEWORK");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s) &&
|
if (target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) {
|
||||||
target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) {
|
|
||||||
// Add the framework directory and the framework item itself
|
// Add the framework directory and the framework item itself
|
||||||
auto fwItems = this->GlobalGenerator->SplitFrameworkPath(item.Value, true);
|
auto fwItems = this->GlobalGenerator->SplitFrameworkPath(item.Value, true);
|
||||||
if (!fwItems) {
|
if (!fwItems) {
|
||||||
@@ -1571,8 +1570,15 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
|
|||||||
// Add the directory portion to the framework search path.
|
// Add the directory portion to the framework search path.
|
||||||
this->AddFrameworkPath(fwItems->first);
|
this->AddFrameworkPath(fwItems->first);
|
||||||
}
|
}
|
||||||
this->Items.emplace_back(fwItems->second, ItemIsPath::Yes, target,
|
if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s)) {
|
||||||
this->FindLibraryFeature(entry.Feature));
|
this->Items.emplace_back(fwItems->second, 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 {
|
} else {
|
||||||
// Now add the full path to the library.
|
// Now add the full path to the library.
|
||||||
this->Items.emplace_back(
|
this->Items.emplace_back(
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.22...3.24)
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
# Create framework and ensure header is placed in Headers
|
||||||
|
set(input_header "${CMAKE_SOURCE_DIR}/Gui.h")
|
||||||
|
add_library(Gui SHARED Gui.c "${input_header}")
|
||||||
|
set_target_properties(Gui PROPERTIES
|
||||||
|
PUBLIC_HEADER "${input_header}"
|
||||||
|
FRAMEWORK TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(app main.c)
|
||||||
|
|
||||||
|
target_link_libraries(app PRIVATE Gui)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
int foo(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
int foo(void);
|
||||||
@@ -105,3 +105,15 @@ function(framework_system_include_test)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
framework_system_include_test()
|
framework_system_include_test()
|
||||||
|
|
||||||
|
function(framework_consumption)
|
||||||
|
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/FrameworkConsumption-build")
|
||||||
|
set(RunCMake_TEST_NO_CLEAN 1)
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
run_cmake(FrameworkConsumption)
|
||||||
|
run_cmake_command(FrameworkConsumption-build ${CMAKE_COMMAND} --build .)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
framework_consumption()
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
#include <Gui/Gui.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
foo();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user