summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-16 14:13:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-11-16 14:13:16 (GMT)
commit2c923a7e28d668a193cd5e444c1f6c4a995d544a (patch)
tree59c41b2ab38a78cebd7fd0c951aab22ded994658 /Tests
parentf6d65c622c40ed0f7b0da9d8b17aa22c203fd48c (diff)
parent37bc3400cd5abd2e9f34a9da726dcffed709f9d4 (diff)
downloadCMake-2c923a7e28d668a193cd5e444c1f6c4a995d544a.zip
CMake-2c923a7e28d668a193cd5e444c1f6c4a995d544a.tar.gz
CMake-2c923a7e28d668a193cd5e444c1f6c4a995d544a.tar.bz2
Merge topic 'install-export-xcframework'
37bc3400cd CMakePackageConfigHelpers: Add generate_apple_platform_selection_file() 256bb0cc40 install(EXPORT): Add ability to point to .xcframework file a90968e044 cmExportBuildFileGenerator: Add structs for target exports Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Jason Juang <jasjuang@gmail.com> Merge-request: !8969
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/XcFramework/RunCMakeTest.cmake125
-rw-r--r--Tests/RunCMake/XcFramework/export-macos.cmake44
-rw-r--r--Tests/RunCMake/XcFramework/import-common.cmake5
-rw-r--r--Tests/RunCMake/XcFramework/import-genex-common.cmake5
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-build-general-build-stdout.txt2
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-build-general.cmake1
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-build-specific-build-stdout.txt2
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-build-specific-genex-build-stdout.txt2
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-build-specific-genex.cmake1
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-build-specific.cmake1
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-general-build-stdout.txt2
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-general.cmake1
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-specific-build-stdout.txt2
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-specific-genex-build-stdout.txt2
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-specific-genex.cmake1
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework-build-stdout.txt2
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework.cmake1
-rw-r--r--Tests/RunCMake/XcFramework/import-macos-install-specific.cmake1
-rw-r--r--Tests/RunCMake/XcFramework/mylib-config.cmake.in3
19 files changed, 203 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcFramework/RunCMakeTest.cmake b/Tests/RunCMake/XcFramework/RunCMakeTest.cmake
index 9a13892..1fef283 100644
--- a/Tests/RunCMake/XcFramework/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcFramework/RunCMakeTest.cmake
@@ -119,3 +119,128 @@ unset(RunCMake_TEST_BINARY_DIR)
run_cmake(find-library)
run_cmake_command(find-library-script ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/find-library.cmake)
+
+file(REMOVE_RECURSE ${RunCMake_BINARY_DIR}/export-install)
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/export-macos-build)
+run_cmake_with_options(export-macos -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/export-install)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+endif()
+run_cmake_command(export-macos-build ${CMAKE_COMMAND} --build . ${_config_arg})
+run_cmake_command(export-macos-install ${CMAKE_COMMAND} --install . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/import-macos-install-specific-no-xcframework-build)
+run_cmake_with_options(import-macos-install-specific-no-xcframework -DCMAKE_SYSTEM_NAME=Darwin -Dmylib_DIR=${RunCMake_BINARY_DIR}/export-install/lib/macos/cmake/mylib)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+set(_config_dir)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+ set(_config_dir /Release)
+endif()
+run_cmake_command(import-macos-install-specific-no-xcframework-build ${CMAKE_COMMAND} --build . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/export-macos-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15)
+ # 'xcodebuild -create-xcframework' fails on symlinked paths.
+ file(REAL_PATH "${RunCMake_SOURCE_DIR}" src_dir)
+ file(REAL_PATH "${RunCMake_BINARY_DIR}" bld_dir)
+else()
+ set(src_dir "${RunCMake_SOURCE_DIR}")
+ set(bld_dir "${RunCMake_BINARY_DIR}")
+endif()
+run_cmake_command(export-install-xcframework xcodebuild -create-xcframework
+ -output ${bld_dir}/export-install/lib/mylib.xcframework
+ -library ${bld_dir}/export-install/lib/macos/libmylib.a
+ -headers ${src_dir}/mylib/include
+ )
+run_cmake_command(export-build-xcframework xcodebuild -create-xcframework
+ -output ${bld_dir}/export-macos-build/lib/mylib.xcframework
+ -library ${bld_dir}/export-macos-build/lib/macos${_config_dir}/libmylib.a
+ -headers ${src_dir}/mylib/include
+ )
+run_cmake_command(export-install-xcframework-genex xcodebuild -create-xcframework
+ -output ${bld_dir}/export-install/lib2/mylib-genex.xcframework
+ -library ${bld_dir}/export-install/lib/macos/libmylib-genex.a
+ -headers ${src_dir}/mylib/include
+ )
+run_cmake_command(export-build-xcframework-genex xcodebuild -create-xcframework
+ -output ${bld_dir}/export-macos-build/lib/mylib-genex.xcframework
+ -library ${bld_dir}/export-macos-build/lib/macos${_config_dir}/libmylib-genex.a
+ -headers ${src_dir}/mylib/include
+ )
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/import-macos-install-specific-build)
+run_cmake_with_options(import-macos-install-specific -DCMAKE_SYSTEM_NAME=Darwin -Dmylib_DIR=${RunCMake_BINARY_DIR}/export-install/lib/macos/cmake/mylib)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+endif()
+run_cmake_command(import-macos-install-specific-build ${CMAKE_COMMAND} --build . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/import-macos-build-specific-build)
+run_cmake_with_options(import-macos-build-specific -DCMAKE_SYSTEM_NAME=Darwin -Dmylib_DIR=${RunCMake_BINARY_DIR}/export-macos-build/lib/macos/cmake/mylib)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+endif()
+run_cmake_command(import-macos-build-specific-build ${CMAKE_COMMAND} --build . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/import-macos-install-specific-genex-build)
+run_cmake_with_options(import-macos-install-specific-genex -DCMAKE_SYSTEM_NAME=Darwin -Dmylib_DIR=${RunCMake_BINARY_DIR}/export-install/lib/macos/cmake/mylib)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+endif()
+run_cmake_command(import-macos-install-specific-genex-build ${CMAKE_COMMAND} --build . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/import-macos-build-specific-genex-build)
+run_cmake_with_options(import-macos-build-specific-genex -DCMAKE_SYSTEM_NAME=Darwin -Dmylib_DIR=${RunCMake_BINARY_DIR}/export-macos-build/lib/macos/cmake/mylib)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+endif()
+run_cmake_command(import-macos-build-specific-genex-build ${CMAKE_COMMAND} --build . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/import-macos-install-general-build)
+run_cmake_with_options(import-macos-install-general -DCMAKE_SYSTEM_NAME=Darwin -Dmylib_DIR=${RunCMake_BINARY_DIR}/export-install/lib/cmake/mylib)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+endif()
+run_cmake_command(import-macos-install-general-build ${CMAKE_COMMAND} --build . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/import-macos-build-general-build)
+run_cmake_with_options(import-macos-build-general -DCMAKE_SYSTEM_NAME=Darwin -Dmylib_DIR=${RunCMake_BINARY_DIR}/export-macos-build/lib/cmake/mylib)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(_config_arg)
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(_config_arg --config Release)
+endif()
+run_cmake_command(import-macos-build-general-build ${CMAKE_COMMAND} --build . ${_config_arg})
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_BINARY_DIR)
diff --git a/Tests/RunCMake/XcFramework/export-macos.cmake b/Tests/RunCMake/XcFramework/export-macos.cmake
new file mode 100644
index 0000000..2fac14f
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/export-macos.cmake
@@ -0,0 +1,44 @@
+enable_language(C)
+
+include(CMakePackageConfigHelpers)
+
+if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
+endif()
+
+if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
+endif()
+
+add_library(mylib STATIC mylib/mylib.c)
+target_include_directories(mylib INTERFACE $<INSTALL_INTERFACE:include>)
+set_property(TARGET mylib PROPERTY ARCHIVE_OUTPUT_DIRECTORY lib/macos)
+
+add_library(mylib-genex STATIC mylib/mylib.c)
+target_include_directories(mylib-genex INTERFACE $<INSTALL_INTERFACE:include>)
+set_property(TARGET mylib-genex PROPERTY ARCHIVE_OUTPUT_DIRECTORY lib/macos)
+
+install(TARGETS mylib mylib-genex DESTINATION lib/macos EXPORT mylib)
+install(FILES mylib/include/mylib/mylib.h DESTINATION include/mylib)
+export(SETUP mylib
+ TARGET mylib XCFRAMEWORK_LOCATION lib/mylib.xcframework
+ TARGET mylib-genex XCFRAMEWORK_LOCATION "$<BUILD_INTERFACE:lib/$<TARGET_PROPERTY:NAME>.xcframework>$<INSTALL_INTERFACE:lib2/$<TARGET_PROPERTY:NAME>.xcframework>"
+ )
+install(EXPORT mylib DESTINATION lib/macos/cmake/mylib FILE mylib-targets.cmake)
+export(EXPORT mylib FILE lib/macos/cmake/mylib/mylib-targets.cmake)
+
+configure_package_config_file(mylib-config.cmake.in mylib-config-sub.cmake INSTALL_DESTINATION lib/macos/cmake/mylib)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mylib-config-sub.cmake DESTINATION lib/macos/cmake/mylib RENAME mylib-config.cmake)
+
+configure_package_config_file(mylib-config.cmake.in lib/macos/cmake/mylib/mylib-config.cmake INSTALL_DESTINATION lib/macos/cmake/mylib)
+
+generate_apple_platform_selection_file(mylib-config-top.cmake
+ INSTALL_DESTINATION lib/cmake/mylib
+ MACOS_CONFIG_FILE lib/macos/cmake/mylib/mylib-config.cmake
+ )
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mylib-config-top.cmake DESTINATION lib/cmake/mylib RENAME mylib-config.cmake)
+
+generate_apple_platform_selection_file(lib/cmake/mylib/mylib-config.cmake
+ INSTALL_DESTINATION lib/cmake/mylib
+ MACOS_CONFIG_FILE lib/macos/cmake/mylib/mylib-config.cmake
+ )
diff --git a/Tests/RunCMake/XcFramework/import-common.cmake b/Tests/RunCMake/XcFramework/import-common.cmake
new file mode 100644
index 0000000..4def6a4
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-common.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+find_package(mylib REQUIRED)
+
+add_custom_target(print_loc ALL COMMAND ${CMAKE_COMMAND} -E echo "mylib location: $<TARGET_FILE:mylib>")
diff --git a/Tests/RunCMake/XcFramework/import-genex-common.cmake b/Tests/RunCMake/XcFramework/import-genex-common.cmake
new file mode 100644
index 0000000..e46902b
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-genex-common.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+find_package(mylib REQUIRED)
+
+add_custom_target(print_loc ALL COMMAND ${CMAKE_COMMAND} -E echo "mylib-genex location: $<TARGET_FILE:mylib-genex>")
diff --git a/Tests/RunCMake/XcFramework/import-macos-build-general-build-stdout.txt b/Tests/RunCMake/XcFramework/import-macos-build-general-build-stdout.txt
new file mode 100644
index 0000000..3ac467d
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-build-general-build-stdout.txt
@@ -0,0 +1,2 @@
+mylib location: [^
+]*/Tests/RunCMake/XcFramework/export-macos-build/lib/mylib\.xcframework/macos-(arm64|x86_64|arm64_x86_64)/libmylib\.a
diff --git a/Tests/RunCMake/XcFramework/import-macos-build-general.cmake b/Tests/RunCMake/XcFramework/import-macos-build-general.cmake
new file mode 100644
index 0000000..08ef6db
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-build-general.cmake
@@ -0,0 +1 @@
+include(import-common.cmake)
diff --git a/Tests/RunCMake/XcFramework/import-macos-build-specific-build-stdout.txt b/Tests/RunCMake/XcFramework/import-macos-build-specific-build-stdout.txt
new file mode 100644
index 0000000..3ac467d
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-build-specific-build-stdout.txt
@@ -0,0 +1,2 @@
+mylib location: [^
+]*/Tests/RunCMake/XcFramework/export-macos-build/lib/mylib\.xcframework/macos-(arm64|x86_64|arm64_x86_64)/libmylib\.a
diff --git a/Tests/RunCMake/XcFramework/import-macos-build-specific-genex-build-stdout.txt b/Tests/RunCMake/XcFramework/import-macos-build-specific-genex-build-stdout.txt
new file mode 100644
index 0000000..d3a20e8
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-build-specific-genex-build-stdout.txt
@@ -0,0 +1,2 @@
+mylib-genex location: [^
+]*/Tests/RunCMake/XcFramework/export-macos-build/lib/mylib-genex\.xcframework/macos-(arm64|x86_64|arm64_x86_64)/libmylib-genex\.a
diff --git a/Tests/RunCMake/XcFramework/import-macos-build-specific-genex.cmake b/Tests/RunCMake/XcFramework/import-macos-build-specific-genex.cmake
new file mode 100644
index 0000000..a061bd3
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-build-specific-genex.cmake
@@ -0,0 +1 @@
+include(import-genex-common.cmake)
diff --git a/Tests/RunCMake/XcFramework/import-macos-build-specific.cmake b/Tests/RunCMake/XcFramework/import-macos-build-specific.cmake
new file mode 100644
index 0000000..08ef6db
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-build-specific.cmake
@@ -0,0 +1 @@
+include(import-common.cmake)
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-general-build-stdout.txt b/Tests/RunCMake/XcFramework/import-macos-install-general-build-stdout.txt
new file mode 100644
index 0000000..1421246
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-general-build-stdout.txt
@@ -0,0 +1,2 @@
+mylib location: [^
+]*/Tests/RunCMake/XcFramework/export-install/lib/mylib\.xcframework/macos-(arm64|x86_64|arm64_x86_64)/libmylib\.a
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-general.cmake b/Tests/RunCMake/XcFramework/import-macos-install-general.cmake
new file mode 100644
index 0000000..08ef6db
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-general.cmake
@@ -0,0 +1 @@
+include(import-common.cmake)
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-specific-build-stdout.txt b/Tests/RunCMake/XcFramework/import-macos-install-specific-build-stdout.txt
new file mode 100644
index 0000000..1421246
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-specific-build-stdout.txt
@@ -0,0 +1,2 @@
+mylib location: [^
+]*/Tests/RunCMake/XcFramework/export-install/lib/mylib\.xcframework/macos-(arm64|x86_64|arm64_x86_64)/libmylib\.a
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-specific-genex-build-stdout.txt b/Tests/RunCMake/XcFramework/import-macos-install-specific-genex-build-stdout.txt
new file mode 100644
index 0000000..5c88758
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-specific-genex-build-stdout.txt
@@ -0,0 +1,2 @@
+mylib-genex location: [^
+]*/Tests/RunCMake/XcFramework/export-install/lib2/mylib-genex\.xcframework/macos-(arm64|x86_64|arm64_x86_64)/libmylib-genex\.a
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-specific-genex.cmake b/Tests/RunCMake/XcFramework/import-macos-install-specific-genex.cmake
new file mode 100644
index 0000000..a061bd3
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-specific-genex.cmake
@@ -0,0 +1 @@
+include(import-genex-common.cmake)
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework-build-stdout.txt b/Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework-build-stdout.txt
new file mode 100644
index 0000000..1c92972
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework-build-stdout.txt
@@ -0,0 +1,2 @@
+mylib location: [^
+]*/Tests/RunCMake/XcFramework/export-install/lib/macos/libmylib\.a
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework.cmake b/Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework.cmake
new file mode 100644
index 0000000..08ef6db
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-specific-no-xcframework.cmake
@@ -0,0 +1 @@
+include(import-common.cmake)
diff --git a/Tests/RunCMake/XcFramework/import-macos-install-specific.cmake b/Tests/RunCMake/XcFramework/import-macos-install-specific.cmake
new file mode 100644
index 0000000..08ef6db
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/import-macos-install-specific.cmake
@@ -0,0 +1 @@
+include(import-common.cmake)
diff --git a/Tests/RunCMake/XcFramework/mylib-config.cmake.in b/Tests/RunCMake/XcFramework/mylib-config.cmake.in
new file mode 100644
index 0000000..878d6e8
--- /dev/null
+++ b/Tests/RunCMake/XcFramework/mylib-config.cmake.in
@@ -0,0 +1,3 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/mylib-targets.cmake")