From c404d7f221f170f01bc10247438bf1d011d8997a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Dec 2020 13:06:25 -0500 Subject: Tests: Add cache entry to control XCTest deployment target --- Tests/CMakeLists.txt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4938681..8877115 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1833,11 +1833,22 @@ if(BUILD_TESTING) ) endif() - if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5 - AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") - set(XCTest_CTEST_OPTIONS --build-config $) - set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1} -DCMAKE_OSX_SYSROOT=macosx) - ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $ -V) + if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5) + if(NOT CMake_TEST_XCTest_DEPLOYMENT_TARGET) + execute_process( + COMMAND sw_vers -productVersion + OUTPUT_VARIABLE OSX_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") + set(CMake_TEST_XCTest_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}") + endif() + endif() + if(CMake_TEST_XCTest_DEPLOYMENT_TARGET) + set(XCTest_CTEST_OPTIONS --build-config $) + set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMake_TEST_XCTest_DEPLOYMENT_TARGET} -DCMAKE_OSX_SYSROOT=macosx) + ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $ -V) + endif() endif() add_test(linkorder1 ${CMAKE_CTEST_COMMAND} -- cgit v0.12