diff options
Diffstat (limited to 'Tests/RunCMake/XcodeProject-Device')
30 files changed, 821 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject-Device/CMakeLists.txt b/Tests/RunCMake/XcodeProject-Device/CMakeLists.txt new file mode 100644 index 0000000..93ee9df --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c new file mode 100644 index 0000000..5e0f40f --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c @@ -0,0 +1,26 @@ +#include <Availability.h> +#include <TargetConditionals.h> + +#if TARGET_OS_OSX +# if __MAC_OS_X_VERSION_MIN_REQUIRED != __MAC_10_11 +# error macOS deployment version mismatch +# endif +#elif TARGET_OS_IOS +# if __IPHONE_OS_VERSION_MIN_REQUIRED != __IPHONE_9_1 +# error iOS deployment version mismatch +# endif +#elif TARGET_OS_WATCH +# if __WATCH_OS_VERSION_MIN_REQUIRED != __WATCHOS_2_0 +# error watchOS deployment version mismatch +# endif +#elif TARGET_OS_TV +# if __TV_OS_VERSION_MIN_REQUIRED != __TVOS_9_0 +# error tvOS deployment version mismatch +# endif +#else +# error unknown OS +#endif + +void foo() +{ +} diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake new file mode 100644 index 0000000..234ceef --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake @@ -0,0 +1,27 @@ +enable_language(C) + +# using Xcode 7.1 SDK versions for deployment targets + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(CMAKE_OSX_DEPLOYMENT_TARGET "9.1") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS") + set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") + set(CMAKE_OSX_DEPLOYMENT_TARGET "9.0") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +else() + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11") +endif() + +add_library(myFramework STATIC DeploymentTarget.c) +set_target_properties(myFramework PROPERTIES FRAMEWORK TRUE) diff --git a/Tests/RunCMake/XcodeProject-Device/EffectivePlatformNameOFF.cmake b/Tests/RunCMake/XcodeProject-Device/EffectivePlatformNameOFF.cmake new file mode 100644 index 0000000..4a3bf56 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/EffectivePlatformNameOFF.cmake @@ -0,0 +1,12 @@ +enable_language(CXX) + +set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME OFF) + +set(CMAKE_MACOSX_BUNDLE true) + +add_library(library STATIC foo.cpp) + +add_executable(main main.cpp) +target_link_libraries(main library) + +install(TARGETS library ARCHIVE DESTINATION lib) diff --git a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake new file mode 100644 index 0000000..e2ed045 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake @@ -0,0 +1,303 @@ +include(RunCMake) + +# Isolate device tests from host architecture selection. +unset(ENV{CMAKE_OSX_ARCHITECTURES}) + +if(NOT XCODE_VERSION VERSION_LESS 5) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeInstallIOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeInstallIOS) + run_cmake_command(XcodeInstallIOS-install ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=Darwin" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build-macOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-macOS ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build-iOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-iOS ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + +if(NOT XCODE_VERSION VERSION_LESS 7) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesWatchOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=watchOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build-watchOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-watchOS ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + +if(NOT XCODE_VERSION VERSION_LESS 7.1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesTvOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=tvOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build-tvOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-tvOS ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + +if(NOT XCODE_VERSION VERSION_LESS 7) + set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake") + run_cmake(XcodeTbdStub) + unset(RunCMake_TEST_OPTIONS) +endif() + +if(XCODE_VERSION VERSION_GREATER_EQUAL 6) + # XcodeIOSInstallCombined + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeIOSInstallCombined) + run_cmake_command(XcodeIOSInstallCombined-build ${CMAKE_COMMAND} --build .) + if(XCODE_VERSION VERSION_LESS 12) + run_cmake_command(XcodeIOSInstallCombined-install ${CMAKE_COMMAND} --build . --target install) + endif() + # --build defaults to Debug, --install defaults to Release, so we have to + # specify the configuration explicitly + run_cmake_command(XcodeIOSInstallCombined-cmakeinstall + ${CMAKE_COMMAND} --install . --config Debug + ) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + + # XcodeIOSInstallCombinedPrune + # FIXME(#24011): Xcode 14 removed support for older architectures the test needs. + if(XCODE_VERSION VERSION_LESS 14) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedPrune-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeIOSInstallCombinedPrune) + run_cmake_command(XcodeIOSInstallCombinedPrune-build ${CMAKE_COMMAND} --build .) + if(XCODE_VERSION VERSION_LESS 12) + run_cmake_command(XcodeIOSInstallCombinedPrune-install ${CMAKE_COMMAND} --build . --target install) + endif() + # --build defaults to Debug, --install defaults to Release, so we have to + # specify the configuration explicitly + run_cmake_command(XcodeIOSInstallCombinedPrune-cmakeinstall + ${CMAKE_COMMAND} --install . --config Debug + ) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + endif() + + # XcodeIOSInstallCombinedSingleArch + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedSingleArch-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeIOSInstallCombinedSingleArch) + run_cmake_command(XcodeIOSInstallCombinedSingleArch-build ${CMAKE_COMMAND} --build .) + if(XCODE_VERSION VERSION_LESS 12) + run_cmake_command(XcodeIOSInstallCombinedSingleArch-install ${CMAKE_COMMAND} --build . --target install) + endif() + # --build defaults to Debug, --install defaults to Release, so we have to + # specify the configuration explicitly + run_cmake_command(XcodeIOSInstallCombinedSingleArch-cmakeinstall + ${CMAKE_COMMAND} --install . --config Debug + ) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + +if(NOT XCODE_VERSION VERSION_LESS 5) + # XcodeMultiplatform + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeMultiplatform-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "${IOS_DEPLOYMENT_TARGET}") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeMultiplatform) + + # build ios before macos + run_cmake_command(XcodeMultiplatform-iphonesimulator-build ${CMAKE_COMMAND} --build . -- -sdk iphonesimulator) + run_cmake_command(XcodeMultiplatform-iphonesimulator-install ${CMAKE_COMMAND} --build . --target install -- -sdk iphonesimulator DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_iphonesimulator) + + run_cmake_command(XcodeMultiplatform-macosx-build ${CMAKE_COMMAND} --build . -- -sdk macosx) + run_cmake_command(XcodeMultiplatform-macosx-install ${CMAKE_COMMAND} --build . --target install -- -sdk macosx DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_macosx) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) + + # EffectivePlatformNameOFF + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/EffectivePlatformNameOFF-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_OSX_SYSROOT=iphonesimulator") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(EffectivePlatformNameOFF) + + run_cmake_command(EffectivePlatformNameOFF-iphonesimulator-build ${CMAKE_COMMAND} --build .) + run_cmake_command(EffectivePlatformNameOFF-iphonesimulator-install ${CMAKE_COMMAND} --build . --target install -- DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_iphonesimulator) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + function(deployment_target_test SystemName SDK) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DeploymentTarget-${SDK}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(DeploymentTarget) + run_cmake_command(DeploymentTarget-${SDK} ${CMAKE_COMMAND} --build .) + endfunction() + + deployment_target_test(Darwin macosx) + deployment_target_test(iOS iphoneos) + deployment_target_test(iOS iphonesimulator) + deployment_target_test(tvOS appletvos) + deployment_target_test(tvOS appletvsimulator) + deployment_target_test(watchOS watchos) + deployment_target_test(watchOS watchsimulator) +endif() + +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + function(xctest_lookup_test SystemName SDK) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XCTestLookup-${SDK}-build) + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}") + + run_cmake(XCTestLookup) + endfunction() + + xctest_lookup_test(Darwin macosx) + xctest_lookup_test(iOS iphoneos) + xctest_lookup_test(iOS iphonesimulator) + xctest_lookup_test(tvOS appletvos) + xctest_lookup_test(tvOS appletvsimulator) +endif() + +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + function(XcodeRemoveExcessiveISystemSDK SDK) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeRemoveExcessiveISystemSDK-${SDK}-build) + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_OSX_SYSROOT=${SDK}") + run_cmake(XcodeRemoveExcessiveISystem) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(XcodeRemoveExcessiveISystemSDK-${SDK}-build ${CMAKE_COMMAND} --build .) + endfunction() + + XcodeRemoveExcessiveISystemSDK(iphoneos) + XcodeRemoveExcessiveISystemSDK(iphonesimulator) +endif() + +if (XCODE_VERSION VERSION_GREATER_EQUAL 7.3) + function(xctest_add_bundle_test SystemName SDK BuildSystemVersion ExpectedOutputDir) + set(RunCMake_TEST_BINARY_DIR + ${RunCMake_BINARY_DIR}/DeploymentTarget-${SystemName}-${SDK}-${BuildSystemVersion}-build) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=${SystemName}" + "-DCMAKE_OSX_SYSROOT=${SDK}" + "-DTEST_EXPECTED_OUTPUT_DIR=${ExpectedOutputDir}") + unset(RunCMake_GENERATOR_TOOLSET) + if(BuildSystemVersion) + set(RunCMake_GENERATOR_TOOLSET "buildsystem=${BuildSystemVersion}") + endif() + run_cmake(XCTestAddBundle) + endfunction() + + if(XCODE_VERSION VERSION_GREATER_EQUAL 12) + xctest_add_bundle_test(Darwin macosx "1" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + xctest_add_bundle_test(Darwin macosx "12" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + xctest_add_bundle_test(iOS iphonesimulator "1" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + if (XCODE_VERSION VERSION_LESS 12.5) + xctest_add_bundle_test(iOS iphonesimulator "12" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>") + else() + xctest_add_bundle_test(iOS iphonesimulator "12" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + endif() + else() + xctest_add_bundle_test(Darwin macosx "" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + xctest_add_bundle_test(iOS iphonesimulator "" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + endif() +endif() diff --git a/Tests/RunCMake/XcodeProject-Device/XCTestAddBundle.cmake b/Tests/RunCMake/XcodeProject-Device/XCTestAddBundle.cmake new file mode 100644 index 0000000..9114fee --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XCTestAddBundle.cmake @@ -0,0 +1,22 @@ +enable_language(Swift) + +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +find_package(XCTest REQUIRED) + +add_executable(TestedApp MACOSX_BUNDLE dummy_main.swift) + +xctest_add_bundle(TestingAppBundle TestedApp dummy_main.swift) + +get_target_property(_lib_output_dir TestingAppBundle LIBRARY_OUTPUT_DIRECTORY) + +if (NOT DEFINED TEST_EXPECTED_OUTPUT_DIR) + message(FATAL_ERROR "Testing variable TEST_EXPECTED_OUTPUT_DIR is not set") +endif() + +if (NOT _lib_output_dir STREQUAL TEST_EXPECTED_OUTPUT_DIR) + message(SEND_ERROR "Property LIBRARY_OUTPUT_DIRECTORY is expected to be ${TEST_EXPECTED_OUTPUT_DIR} " + "but was ${_lib_output_dir}") +endif() diff --git a/Tests/RunCMake/XcodeProject-Device/XCTestLookup.cmake b/Tests/RunCMake/XcodeProject-Device/XCTestLookup.cmake new file mode 100644 index 0000000..77676e5 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XCTestLookup.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +find_package(XCTest REQUIRED) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeBundles-install-check.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeBundles-install-check.cmake new file mode 100644 index 0000000..758d730 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeBundles-install-check.cmake @@ -0,0 +1,8 @@ +file(GLOB DIRECTORIES LIST_DIRECTORIES true + "${RunCMake_TEST_BINARY_DIR}/_install/FooExtension/*.*") + +foreach(DIRECTORY IN LISTS DIRECTORIES) + if(NOT DIRECTORY MATCHES "\\.foo$") + message(SEND_ERROR "Extension does not match ${DIRECTORY}") + endif() +endforeach() diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake new file mode 100644 index 0000000..a9fafd2 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake @@ -0,0 +1,143 @@ +# check if Xcode and CMake have the same understanding of Bundle layout + +enable_language(C) + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +endif() + +# App Bundle + +add_executable(AppBundle MACOSX_BUNDLE main.m) + +add_custom_target(AppBundleTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:AppBundle>" "$<TARGET_FILE:AppBundle>.old") + +add_dependencies(AppBundleTest AppBundle) + +# with custom extension + +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + add_executable(AppBundleExt MACOSX_BUNDLE main.m) + set_target_properties(AppBundleExt PROPERTIES BUNDLE_EXTENSION "foo") + install(TARGETS AppBundleExt BUNDLE DESTINATION FooExtension) + + add_custom_target(AppBundleExtTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:AppBundleExt>" "$<TARGET_FILE:AppBundleExt>.old") + + add_dependencies(AppBundleExtTest AppBundleExt) +endif() + +# Shared Framework (not supported for iOS on Xcode < 6) + +if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS" OR NOT XCODE_VERSION VERSION_LESS 6) + add_library(SharedFramework SHARED main.c) + set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE) + + add_custom_target(SharedFrameworkTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_DIR:SharedFramework>" "$<TARGET_BUNDLE_DIR:SharedFramework>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_CONTENT_DIR:SharedFramework>" "$<TARGET_BUNDLE_CONTENT_DIR:SharedFramework>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:SharedFramework>" "$<TARGET_FILE:SharedFramework>.old") + + add_dependencies(SharedFrameworkTest SharedFramework) + + # with custom extension + + add_library(SharedFrameworkExt SHARED main.c) + set_target_properties(SharedFrameworkExt PROPERTIES FRAMEWORK TRUE) + set_target_properties(SharedFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo") + install(TARGETS SharedFrameworkExt FRAMEWORK DESTINATION FooExtension) + + add_custom_target(SharedFrameworkExtTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_DIR:SharedFrameworkExt>" "$<TARGET_BUNDLE_DIR:SharedFrameworkExt>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_CONTENT_DIR:SharedFrameworkExt>" "$<TARGET_BUNDLE_CONTENT_DIR:SharedFrameworkExt>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:SharedFrameworkExt>" "$<TARGET_FILE:SharedFrameworkExt>.old") + + add_dependencies(SharedFrameworkExtTest SharedFrameworkExt) +endif() + +# Static Framework (not supported for Xcode < 6) + +if(NOT XCODE_VERSION VERSION_LESS 6) + add_library(StaticFramework STATIC main.c) + set_target_properties(StaticFramework PROPERTIES FRAMEWORK TRUE) + + add_custom_target(StaticFrameworkTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_DIR:StaticFramework>" "$<TARGET_BUNDLE_DIR:StaticFramework>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_CONTENT_DIR:StaticFramework>" "$<TARGET_BUNDLE_CONTENT_DIR:StaticFramework>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:StaticFramework>" "$<TARGET_FILE:StaticFramework>.old") + + add_dependencies(StaticFrameworkTest StaticFramework) + + # with custom extension + + add_library(StaticFrameworkExt STATIC main.c) + set_target_properties(StaticFrameworkExt PROPERTIES FRAMEWORK TRUE) + set_target_properties(StaticFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo") + install(TARGETS StaticFrameworkExt FRAMEWORK DESTINATION StaticFooExtension) + + add_custom_target(StaticFrameworkExtTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_DIR:StaticFrameworkExt>" "$<TARGET_BUNDLE_DIR:StaticFrameworkExt>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_CONTENT_DIR:StaticFrameworkExt>" "$<TARGET_BUNDLE_CONTENT_DIR:StaticFrameworkExt>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:StaticFrameworkExt>" "$<TARGET_FILE:StaticFrameworkExt>.old") + + add_dependencies(StaticFrameworkExtTest StaticFrameworkExt) +endif() + +# Bundle + +if(NOT CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE) + add_library(Bundle MODULE main.c) + set_target_properties(Bundle PROPERTIES BUNDLE TRUE) + + add_custom_target(BundleTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_DIR:Bundle>" "$<TARGET_BUNDLE_DIR:Bundle>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_CONTENT_DIR:Bundle>" "$<TARGET_BUNDLE_CONTENT_DIR:Bundle>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:Bundle>" "$<TARGET_FILE:Bundle>.old") + + add_dependencies(BundleTest Bundle) + + # with custom extension + + add_library(BundleExt MODULE main.c) + set_target_properties(BundleExt PROPERTIES BUNDLE TRUE) + set_target_properties(BundleExt PROPERTIES BUNDLE_EXTENSION "foo") + install(TARGETS BundleExt LIBRARY DESTINATION FooExtension) + + add_custom_target(BundleExtTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_DIR:BundleExt>" "$<TARGET_BUNDLE_DIR:BundleExt>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_BUNDLE_CONTENT_DIR:BundleExt>" "$<TARGET_BUNDLE_CONTENT_DIR:BundleExt>.old" + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:BundleExt>" "$<TARGET_FILE:BundleExt>.old") + + add_dependencies(BundleExtTest BundleExt) +endif() diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined-cmakeinstall-check.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined-cmakeinstall-check.cmake new file mode 100644 index 0000000..a1ceb13 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined-cmakeinstall-check.cmake @@ -0,0 +1,2 @@ +# Expect the same results whether installing directly or via cmake --install +include(${CMAKE_CURRENT_LIST_DIR}/XcodeIOSInstallCombined-install-check.cmake) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined-install-check.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined-install-check.cmake new file mode 100644 index 0000000..60bc0d8 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined-install-check.cmake @@ -0,0 +1,37 @@ +function(verify_architectures file) + execute_process( + COMMAND xcrun otool -vf ${RunCMake_TEST_BINARY_DIR}/_install/${file} + OUTPUT_VARIABLE otool_out + ERROR_VARIABLE otool_err + RESULT_VARIABLE otool_result) + if(NOT otool_result EQUAL "0") + message(SEND_ERROR "Could not retrieve fat headers: ${otool_err}") + return() + endif() + + string(REGEX MATCHALL "\narchitecture [^ \n\t()]+" architectures "${otool_out}") + string(REPLACE "\narchitecture " "" actual "${architectures}") + list(SORT actual) + + if(XCODE_VERSION VERSION_LESS 14) + set(maybe_armv7 armv7) + set(maybe_i386 i386) + else() + set(maybe_armv7 "") + set(maybe_i386 "") + endif() + set(expected arm64 ${maybe_armv7} ${maybe_i386} x86_64) + + if(NOT actual STREQUAL expected) + message(SEND_ERROR + "The actual library contains the architectures:\n ${actual} \n" + "which do not match expected ones:\n ${expected} \n" + "otool output:\n${otool_out}") + endif() +endfunction() + +verify_architectures(bin/foo_app.app/foo_app) +verify_architectures(lib/libfoo_static.a) +verify_architectures(lib/libfoo_shared.dylib) +verify_architectures(lib/foo_bundle.bundle/foo_bundle) +verify_architectures(lib/foo_framework.framework/foo_framework) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined.cmake new file mode 100644 index 0000000..f8eccc7 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombined.cmake @@ -0,0 +1,40 @@ +enable_language(CXX) + +set(maybe_armv7 armv7) +set(maybe_i386 i386) +if(XCODE_VERSION VERSION_GREATER_EQUAL 14) + set(CMAKE_OSX_DEPLOYMENT_TARGET 16) + set(maybe_armv7 "") + set(maybe_i386 "") +elseif(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() + +if(NOT IOS) + message(FATAL_ERROR "IOS variable is not set") +endif() + +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") +set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") +set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") + +set(CMAKE_OSX_ARCHITECTURES ${maybe_armv7} arm64 ${maybe_i386} x86_64) + +add_executable(foo_app MACOSX_BUNDLE main.cpp) +install(TARGETS foo_app BUNDLE DESTINATION bin) + +add_library(foo_static STATIC foo.cpp) +install(TARGETS foo_static ARCHIVE DESTINATION lib) + +add_library(foo_shared SHARED foo.cpp) +install(TARGETS foo_shared LIBRARY DESTINATION lib) + +add_library(foo_bundle MODULE foo.cpp) +set_target_properties(foo_bundle PROPERTIES BUNDLE TRUE) +install(TARGETS foo_bundle LIBRARY DESTINATION lib) + +add_library(foo_framework SHARED foo.cpp) +set_target_properties(foo_framework PROPERTIES FRAMEWORK TRUE) +install(TARGETS foo_framework FRAMEWORK DESTINATION lib) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune-install-check.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune-install-check.cmake new file mode 100644 index 0000000..37bb4d5 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune-install-check.cmake @@ -0,0 +1,26 @@ +function(verify_architectures file) + execute_process( + COMMAND xcrun otool -vf ${RunCMake_TEST_BINARY_DIR}/_install/${file} + OUTPUT_VARIABLE otool_out + ERROR_VARIABLE otool_err + RESULT_VARIABLE otool_result) + if(NOT otool_result EQUAL "0") + message(SEND_ERROR "Could not retrieve fat headers: ${otool_err}") + return() + endif() + + string(REGEX MATCHALL "\narchitecture [^ \n\t()]+" architectures ${otool_out}) + string(REPLACE "\narchitecture " "" actual "${architectures}") + list(SORT actual) + + set(expected armv7 x86_64) + + if(NOT actual STREQUAL expected) + message(SEND_ERROR + "The actual library contains the architectures:\n ${actual} \n" + "which do not match expected ones:\n ${expected} \n" + "otool output:\n${otool_out}") + endif() +endfunction() + +verify_architectures(lib/libfoo.dylib) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune-install-stdout.txt b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune-install-stdout.txt new file mode 100644 index 0000000..c87008a --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune-install-stdout.txt @@ -0,0 +1,2 @@ +.*Unexpected architecture `i386` detected.* +.*Unexpected architecture `arm64` detected.* diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune.cmake new file mode 100644 index 0000000..e719428 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedPrune.cmake @@ -0,0 +1,39 @@ +enable_language(CXX) + +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() + +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") +set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") + +add_library(foo SHARED foo.cpp) +install(TARGETS foo DESTINATION lib) + +add_library(baz SHARED foo.cpp) +set_target_properties( + foo baz + PROPERTIES + XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] armv7 + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] armv7 + XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] x86_64 + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] x86_64 +) + +add_library(boo SHARED foo.cpp) +set_target_properties( + boo + PROPERTIES + XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] arm64 + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] arm64 + XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] i386 + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] i386 +) + +add_custom_command( + TARGET foo + POST_BUILD + COMMAND lipo -create $<TARGET_FILE:baz> $<TARGET_FILE:boo> -output $<TARGET_FILE:foo> +) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch-cmakeinstall-check.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch-cmakeinstall-check.cmake new file mode 100644 index 0000000..3f7c379 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch-cmakeinstall-check.cmake @@ -0,0 +1,2 @@ +# Expect the same results whether installing directly or via cmake --install +include(${CMAKE_CURRENT_LIST_DIR}/XcodeIOSInstallCombinedSingleArch-install-check.cmake) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch-install-check.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch-install-check.cmake new file mode 100644 index 0000000..db8f869 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch-install-check.cmake @@ -0,0 +1,29 @@ +function(verify_architecture file) + execute_process( + COMMAND xcrun lipo -info ${RunCMake_TEST_BINARY_DIR}/_install/${file} + OUTPUT_VARIABLE lipo_out + ERROR_VARIABLE lipo_err + RESULT_VARIABLE lipo_result) + if(NOT lipo_result EQUAL "0") + message(SEND_ERROR "lipo -info failed: ${lipo_err}") + return() + endif() + + string(REGEX MATCHALL "is architecture: [^ \n\t]+" architecture "${lipo_out}") + string(REGEX REPLACE "is architecture: " "" actual "${architecture}") + + if(XCODE_VERSION VERSION_GREATER_EQUAL 14) + set(expected arm64) + else() + set(expected armv7) + endif() + + if(NOT actual STREQUAL expected) + message(SEND_ERROR + "The actual library architecture:\n ${actual} \n" + "which do not match expected ones:\n ${expected} \n" + "lipo output:\n${lipo_out}") + endif() +endfunction() + +verify_architecture(lib/libfoo.dylib) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch.cmake new file mode 100644 index 0000000..cb22e51 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeIOSInstallCombinedSingleArch.cmake @@ -0,0 +1,26 @@ +enable_language(CXX) + +set(iphoneos_arch armv7) +if(XCODE_VERSION VERSION_GREATER_EQUAL 14) + set(CMAKE_OSX_DEPLOYMENT_TARGET 16) + set(iphoneos_arch arm64) +elseif(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() + +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") +set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") + +add_library(foo SHARED foo.cpp) +install(TARGETS foo DESTINATION lib) + +set_target_properties( + foo + PROPERTIES + XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] ${iphoneos_arch} + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] ${iphoneos_arch} + XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "" + XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "" +) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeInstallIOS-install-stdout.txt b/Tests/RunCMake/XcodeProject-Device/XcodeInstallIOS-install-stdout.txt new file mode 100644 index 0000000..f2478be --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeInstallIOS-install-stdout.txt @@ -0,0 +1,2 @@ +-- Install configuration: .* +-- Installing: .*/ios_install/lib/libfoo.a diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeInstallIOS.cmake new file mode 100644 index 0000000..fccd4c6 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeInstallIOS.cmake @@ -0,0 +1,7 @@ +enable_language(CXX) + +set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") + +add_library(foo STATIC foo.cpp) +install(TARGETS foo ARCHIVE DESTINATION lib) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeMultiplatform.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeMultiplatform.cmake new file mode 100644 index 0000000..b334b7d --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeMultiplatform.cmake @@ -0,0 +1,13 @@ +enable_language(CXX) + +set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME ON) + +set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx iphonesimulator") +set(CMAKE_MACOSX_BUNDLE true) + +add_library(library STATIC foo.cpp) + +add_executable(main main.cpp) +target_link_libraries(main library) + +install(TARGETS library ARCHIVE DESTINATION lib) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeRemoveExcessiveISystem.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeRemoveExcessiveISystem.cmake new file mode 100644 index 0000000..b28a58e --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeRemoveExcessiveISystem.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/../XcodeProject/XcodeRemoveExcessiveISystem.cmake) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeTbdStub-stdout.txt b/Tests/RunCMake/XcodeProject-Device/XcodeTbdStub-stdout.txt new file mode 100644 index 0000000..9d9e143 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeTbdStub-stdout.txt @@ -0,0 +1 @@ +.*/libz\.tbd.* diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeTbdStub.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeTbdStub.cmake new file mode 100644 index 0000000..55dd1a7 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/XcodeTbdStub.cmake @@ -0,0 +1 @@ +find_package(ZLIB REQUIRED) diff --git a/Tests/RunCMake/XcodeProject-Device/dummy_main.swift b/Tests/RunCMake/XcodeProject-Device/dummy_main.swift new file mode 100644 index 0000000..1aaee42 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/dummy_main.swift @@ -0,0 +1,18 @@ +#if os(iOS) +import UIKit + +@UIApplicationMain +class MyApp: UIResponder, UIApplicationDelegate { +} + +#elseif os(macOS) +import SwiftUI + +@main +struct MyApp: App { + var body: some Scene { + WindowGroup { + } + } +} +#endif diff --git a/Tests/RunCMake/XcodeProject-Device/foo.cpp b/Tests/RunCMake/XcodeProject-Device/foo.cpp new file mode 100644 index 0000000..3695dc9 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/foo.cpp @@ -0,0 +1,3 @@ +void foo() +{ +} diff --git a/Tests/RunCMake/XcodeProject-Device/main.c b/Tests/RunCMake/XcodeProject-Device/main.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/main.c diff --git a/Tests/RunCMake/XcodeProject-Device/main.cpp b/Tests/RunCMake/XcodeProject-Device/main.cpp new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/XcodeProject-Device/main.m b/Tests/RunCMake/XcodeProject-Device/main.m new file mode 100644 index 0000000..3e70e50 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/main.m @@ -0,0 +1,3 @@ +int main(void) { + return 1; +} diff --git a/Tests/RunCMake/XcodeProject-Device/osx.cmake b/Tests/RunCMake/XcodeProject-Device/osx.cmake new file mode 100644 index 0000000..e021fcd --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Device/osx.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_VERSION 1) +set(UNIX True) +set(APPLE True) + +find_program(XCRUN_EXECUTABLE xcrun) +if(NOT XCRUN_EXECUTABLE) + message(FATAL_ERROR "xcrun not found") +endif() + +execute_process( + COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --show-sdk-path + OUTPUT_VARIABLE OSX_SDK_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "Sysroot used for OSX support") + +set(CMAKE_FIND_ROOT_PATH ${OSX_SDK_PATH} CACHE PATH "Find search path root") |