From 54a5cdbb4c35aa8847d3eb0f7f418fad72563992 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 27 Feb 2015 09:35:50 -0500 Subject: [PATCH] Tests: Compute Xcode version for any generator on OS X Store the version in CMake_TEST_XCODE_VERSION for use by tests that work with any generator on OS X but may depend on the Xcode version providing the tools. --- Tests/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 40bea5117..765fc804c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -172,6 +172,7 @@ if(BUILD_TESTING) ON) mark_as_advanced(CTEST_TEST_CPACK) set(CTEST_TEST_OSX_ARCH 0) + set(CMake_TEST_XCODE_VERSION 0) if(APPLE) execute_process( COMMAND sw_vers -productVersion @@ -185,6 +186,17 @@ if(BUILD_TESTING) else() set(CTEST_TEST_OSX_ARCH 1) endif() + if(XCODE_VERSION) + set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}") + else() + execute_process( + COMMAND xcodebuild -version + OUTPUT_VARIABLE _version ERROR_VARIABLE _version + ) + if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)") + set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}") + endif() + endif() endif() # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,