diff options
Diffstat (limited to 'Tests/RunCMake/XcodeProject')
7 files changed, 160 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index f89d620..acc0075 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -94,3 +94,39 @@ if(NOT XCODE_VERSION VERSION_LESS 7) run_cmake(XcodeTbdStub) unset(RunCMake_TEST_OPTIONS) endif() + +if(NOT XCODE_VERSION VERSION_LESS 6) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_IOS_INSTALL_COMBINED=YES") + + 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 .) + run_cmake_command(XcodeIOSInstallCombined-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}/XcodeIOSInstallCombinedPrune-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" + "-DCMAKE_IOS_INSTALL_COMBINED=YES") + + 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 .) + run_cmake_command(XcodeIOSInstallCombinedPrune-install ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake new file mode 100644 index 0000000..a1c0671 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake @@ -0,0 +1,30 @@ +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 "architecture [^ \n\t]+" architectures ${otool_out}) + string(REPLACE "architecture " "" actual "${architectures}") + list(SORT actual) + + set(expected arm64 armv7 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/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake new file mode 100644 index 0000000..fc830b1 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.3) + +project(IOSInstallCombined CXX) + +set(CMAKE_OSX_SYSROOT iphoneos) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") +set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") + +set(CMAKE_OSX_ARCHITECTURES "armv7;arm64;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/XcodeIOSInstallCombinedPrune-install-check.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune-install-check.cmake new file mode 100644 index 0000000..83da17d --- /dev/null +++ b/Tests/RunCMake/XcodeProject/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 "architecture [^ \n\t]+" architectures ${otool_out}) + string(REPLACE "architecture " "" 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/XcodeIOSInstallCombinedPrune-install-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune-install-stdout.txt new file mode 100644 index 0000000..28edadc --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune-install-stdout.txt @@ -0,0 +1,2 @@ +.*Unexpected architecture `i386` detected.* +.*Unexpected architecture `arm64` detected.*
\ No newline at end of file diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake new file mode 100644 index 0000000..b47d3a5 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.3) + +project(XcodeIOSInstallCombinedPrune CXX) + +set(CMAKE_OSX_SYSROOT iphoneos) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +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/main.cpp b/Tests/RunCMake/XcodeProject/main.cpp new file mode 100644 index 0000000..1695921 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/main.cpp @@ -0,0 +1,3 @@ +int main(int argc, const char * argv[]) { + return 0; +} |