diff options
Diffstat (limited to 'Tests')
24 files changed, 236 insertions, 0 deletions
diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt index b57761b..2bc2327 100644 --- a/Tests/ObjectLibrary/CMakeLists.txt +++ b/Tests/ObjectLibrary/CMakeLists.txt @@ -77,3 +77,5 @@ add_subdirectory(ExportLanguages) add_subdirectory(LinkObjects) add_subdirectory(Transitive) + +add_subdirectory(TransitiveLinkDeps) diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt b/Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt new file mode 100644 index 0000000..3f561fa --- /dev/null +++ b/Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(implgather INTERFACE) + +add_library(dep STATIC dep.c) + +add_library(deps INTERFACE) +target_link_libraries(deps INTERFACE dep) + +add_library(impl_obj OBJECT impl_obj.c) +target_link_libraries(impl_obj PUBLIC deps) + +target_sources(implgather INTERFACE "$<TARGET_OBJECTS:impl_obj>") +target_link_libraries(implgather INTERFACE impl_obj) + +add_executable(useimpl main.c) +target_link_libraries(useimpl PRIVATE implgather) diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/dep.c b/Tests/ObjectLibrary/TransitiveLinkDeps/dep.c new file mode 100644 index 0000000..7cc62c3 --- /dev/null +++ b/Tests/ObjectLibrary/TransitiveLinkDeps/dep.c @@ -0,0 +1,4 @@ +int from_dep(void) +{ + return 0; +} diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/impl_obj.c b/Tests/ObjectLibrary/TransitiveLinkDeps/impl_obj.c new file mode 100644 index 0000000..f5760b7 --- /dev/null +++ b/Tests/ObjectLibrary/TransitiveLinkDeps/impl_obj.c @@ -0,0 +1,6 @@ +int from_dep(void); + +int impl_obj(void) +{ + return from_dep(); +} diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/main.c b/Tests/ObjectLibrary/TransitiveLinkDeps/main.c new file mode 100644 index 0000000..5661f57 --- /dev/null +++ b/Tests/ObjectLibrary/TransitiveLinkDeps/main.c @@ -0,0 +1,6 @@ +int impl_obj(void); + +int main(int argc, char* argv[]) +{ + return impl_obj(); +} 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") |