From: Brad King <brad.k...@kitware.com>

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 703c548..bcb1590 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,
-- 
2.3.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to