diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2022-03-27 14:08:11 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2022-03-29 11:57:11 (GMT) |
commit | 45ac71d8bcb9c6bc0238a1a772029170cbf354dc (patch) | |
tree | 7ee6cda1a275f8a13345efbec20e129623daebac | |
parent | 2a88b807ce96cd783795f6813a5789e2617175ec (diff) | |
download | CMake-45ac71d8bcb9c6bc0238a1a772029170cbf354dc.zip CMake-45ac71d8bcb9c6bc0238a1a772029170cbf354dc.tar.gz CMake-45ac71d8bcb9c6bc0238a1a772029170cbf354dc.tar.bz2 |
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
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 14 | ||||
-rw-r--r-- | Tests/RunCMake/Framework/FrameworkConsumption.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/Framework/Gui.c | 5 | ||||
-rw-r--r-- | Tests/RunCMake/Framework/Gui.h | 2 | ||||
-rw-r--r-- | Tests/RunCMake/Framework/RunCMakeTest.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/Framework/main.c | 9 |
6 files changed, 53 insertions, 4 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index a1ffc82..e156e3d 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1555,8 +1555,7 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) this->AddLibraryFeature("FRAMEWORK"); } - if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s) && - target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) { + if (target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) { // Add the framework directory and the framework item itself auto fwItems = this->GlobalGenerator->SplitFrameworkPath(item.Value, true); if (!fwItems) { @@ -1571,8 +1570,15 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) // Add the directory portion to the framework search path. this->AddFrameworkPath(fwItems->first); } - this->Items.emplace_back(fwItems->second, ItemIsPath::Yes, target, - this->FindLibraryFeature(entry.Feature)); + if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s)) { + 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 { // Now add the full path to the library. this->Items.emplace_back( diff --git a/Tests/RunCMake/Framework/FrameworkConsumption.cmake b/Tests/RunCMake/Framework/FrameworkConsumption.cmake new file mode 100644 index 0000000..4663166 --- /dev/null +++ b/Tests/RunCMake/Framework/FrameworkConsumption.cmake @@ -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) diff --git a/Tests/RunCMake/Framework/Gui.c b/Tests/RunCMake/Framework/Gui.c new file mode 100644 index 0000000..f669327 --- /dev/null +++ b/Tests/RunCMake/Framework/Gui.c @@ -0,0 +1,5 @@ + +int foo(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Framework/Gui.h b/Tests/RunCMake/Framework/Gui.h new file mode 100644 index 0000000..5beae6d --- /dev/null +++ b/Tests/RunCMake/Framework/Gui.h @@ -0,0 +1,2 @@ + +int foo(void); diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index 2f8fdc7..a767130 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -105,3 +105,15 @@ function(framework_system_include_test) endfunction() 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() diff --git a/Tests/RunCMake/Framework/main.c b/Tests/RunCMake/Framework/main.c new file mode 100644 index 0000000..fc09922 --- /dev/null +++ b/Tests/RunCMake/Framework/main.c @@ -0,0 +1,9 @@ + +#include <Gui/Gui.h> + +int main() +{ + foo(); + + return 0; +} |