diff options
author | Brad King <brad.king@kitware.com> | 2020-12-18 18:44:44 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2021-02-02 23:08:48 (GMT) |
commit | 375b307bae4513b69b9f86549a094da7f2e8b3a7 (patch) | |
tree | edffc1d543ed67866cf80600c0bc3034e304514e /Tests/Framework | |
parent | 0c86d15459eeef2ddd15644b7bb3d7854f226334 (diff) | |
download | CMake-375b307bae4513b69b9f86549a094da7f2e8b3a7.zip CMake-375b307bae4513b69b9f86549a094da7f2e8b3a7.tar.gz CMake-375b307bae4513b69b9f86549a094da7f2e8b3a7.tar.bz2 |
Apple: Fix linking to frameworks that do not exist until build time
Fixes: #21621
Diffstat (limited to 'Tests/Framework')
-rw-r--r-- | Tests/Framework/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/Framework/External/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/Framework/External/external.c | 4 | ||||
-rw-r--r-- | Tests/Framework/useExternal.c | 6 |
4 files changed, 31 insertions, 0 deletions
diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt index a313c2c..f741ec2 100644 --- a/Tests/Framework/CMakeLists.txt +++ b/Tests/Framework/CMakeLists.txt @@ -84,3 +84,19 @@ if(NOT XCODE OR NOT XCODE_VERSION VERSION_LESS 5) endif() include(CPack) + +if(APPLE) + set(ExternalFramework_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/External") + file(REMOVE_RECURSE "${ExternalFramework_INSTALL_DIR}") + + include(ExternalProject) + ExternalProject_Add(ExternalFramework + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/External" + INSTALL_DIR "${ExternalFramework_INSTALL_DIR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> + ) + + add_executable(useExternal useExternal.c) + target_link_libraries(useExternal PRIVATE "${ExternalFramework_INSTALL_DIR}/lib/External.framework") + add_dependencies(useExternal ExternalFramework) +endif() diff --git a/Tests/Framework/External/CMakeLists.txt b/Tests/Framework/External/CMakeLists.txt new file mode 100644 index 0000000..b9128fd --- /dev/null +++ b/Tests/Framework/External/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.19) +project(ExternalFramework C) +add_library(External SHARED external.c) +set_property(TARGET External PROPERTY FRAMEWORK 1) +install(TARGETS External DESTINATION lib) diff --git a/Tests/Framework/External/external.c b/Tests/Framework/External/external.c new file mode 100644 index 0000000..8441e71 --- /dev/null +++ b/Tests/Framework/External/external.c @@ -0,0 +1,4 @@ +int external(void) +{ + return 0; +} diff --git a/Tests/Framework/useExternal.c b/Tests/Framework/useExternal.c new file mode 100644 index 0000000..8494b15 --- /dev/null +++ b/Tests/Framework/useExternal.c @@ -0,0 +1,6 @@ +extern int external(void); + +int main(void) +{ + return external(); +} |