cmake_modules/platform.cmake
branch0.9.20
changeset 9887 6add6157b58e
parent 9860 d419ff107e15
child 9889 54b49e8d8bfa
--- a/cmake_modules/platform.cmake	Tue Dec 31 00:32:55 2013 +0100
+++ b/cmake_modules/platform.cmake	Fri Jan 03 01:40:23 2014 +0100
@@ -74,10 +74,21 @@
     #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on
     #we need to provide the correct one when host and target differ
     if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version})
-        string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version})
-        set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/")
-        add_flag_append(CMAKE_Pascal_FLAGS "-XR${CMAKE_OSX_SYSROOT}")
-        add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version}")
+        find_program(xcrun xcrun)
+        if(xcrun)
+            execute_process(COMMAND ${xcrun} "--show-sdk-path"
+                            OUTPUT_VARIABLE current_sdk_path
+                            OUTPUT_STRIP_TRAILING_WHITESPACE)
+            string(REPLACE "${current_macosx_version}"
+                           "${minimum_macosx_version}"
+                           CMAKE_OSX_SYSROOT
+                           "${current_sdk_path}")
+
+            add_flag_append(CMAKE_Pascal_FLAGS "-XR${CMAKE_OSX_SYSROOT}")
+            add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version}")
+        else()
+            message("*** xcrun not found! Build will work on ${current_macosx_version} only ***")
+        endif()
     endif()
 
     #add user framework directory