mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 10:47:59 +08:00
Tests: Add XCTest cases to cover output directory selection
Fixes: #21800
This commit is contained in:
@@ -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.
|
||||
|
17
Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake
Normal file
17
Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake
Normal file
@@ -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()
|
Reference in New Issue
Block a user