summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-03-16 14:52:21 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-03-16 14:52:28 (GMT)
commitabf9f25d6fb6257bd4ea86a580c6a38530206b78 (patch)
treea4ffcce767c715cb7495eaef8dda22a6150560e5 /Tests
parent3cea13c2f33c9ac46332ba1aa1d5a67042849c7a (diff)
parent74eda8ab1f21ad7ba37dd1fa4f21e158f01d7f1c (diff)
downloadCMake-abf9f25d6fb6257bd4ea86a580c6a38530206b78.zip
CMake-abf9f25d6fb6257bd4ea86a580c6a38530206b78.tar.gz
CMake-abf9f25d6fb6257bd4ea86a580c6a38530206b78.tar.bz2
Merge topic 'tests-for-xctest_add_bundle'
74eda8ab1f Tests: Add XCTest cases to cover output directory selection Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5888
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake26
-rw-r--r--Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake17
2 files changed, 43 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 8b03216..c8b75eb 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -387,4 +387,30 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
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 iphoneos "1" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns")
+ xctest_add_bundle_test(iOS iphoneos "12" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>")
+ else()
+ xctest_add_bundle_test(Darwin macosx "" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns")
+ xctest_add_bundle_test(iOS iphoneos "" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns")
+ endif()
+endif()
# Please add macOS-only tests above before the device-specific tests.
diff --git a/Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake b/Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake
new file mode 100644
index 0000000..444c730
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake
@@ -0,0 +1,17 @@
+enable_language(Swift)
+find_package(XCTest REQUIRED)
+
+add_executable(TestedApp MACOSX_BUNDLE EXCLUDE_FROM_ALL foo.swift)
+
+xctest_add_bundle(TestingAppBundle TestedApp foo.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()