瀏覽代碼

#239 For Mac OS X, must search for SDKs in Applications directory.

Since Xcode 4.3, the "Developer" directory is no longer.

Xcode is now in Applications, so we need to search there for SDKs.

Danielle Pace 12 年之前
父節點
當前提交
91872ff739
共有 1 個文件被更改,包括 22 次插入12 次删除
  1. 22 12
      CMake/ctkBlockSetCMakeOSXVariables.cmake

+ 22 - 12
CMake/ctkBlockSetCMakeOSXVariables.cmake

@@ -48,22 +48,29 @@ if(APPLE)
   set(OSX_SDK_104_NAME "Tiger")
   set(OSX_SDK_105_NAME "Leopard")
   set(OSX_SDK_106_NAME "Snow Leopard")
+  set(OSX_SDK_107_NAME "Lion")
 
+  set(OSX_SDK_ROOTS
+    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
+    /Developer/SDKs
+    )
   set(SDK_VERSIONS_TO_CHECK 10.7 10.6 10.5)
   foreach(SDK_VERSION ${SDK_VERSIONS_TO_CHECK})
     if(NOT CMAKE_OSX_DEPLOYMENT_TARGET OR "${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
-      set(TEST_OSX_SYSROOT "/Developer/SDKs/MacOSX${SDK_VERSION}.sdk")
-      if(EXISTS "${TEST_OSX_SYSROOT}")
-        # Retrieve OSX target name
-        string(REPLACE "." "" sdk_version_no_dot ${SDK_VERSION})
-        set(OSX_NAME ${OSX_SDK_${sdk_version_no_dot}_NAME})
-        set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Force build for 64-bit ${OSX_NAME}." FORCE)
-        set(CMAKE_OSX_DEPLOYMENT_TARGET "${SDK_VERSION}" CACHE STRING "Force build for 64-bit ${OSX_NAME}." FORCE)
-        set(CMAKE_OSX_SYSROOT "${TEST_OSX_SYSROOT}" CACHE PATH "Force build for 64-bit ${OSX_NAME}." FORCE)
-        message(STATUS "Setting OSX_ARCHITECTURES to '${CMAKE_OSX_ARCHITECTURES}' as none was specified.")
-        message(STATUS "Setting OSX_DEPLOYMENT_TARGET to '${SDK_VERSION}' as none was specified.")
-        message(STATUS "Setting OSX_SYSROOT to '${TEST_OSX_SYSROOT}' as none was specified.")
-      endif()
+      foreach(SDK_ROOT ${OSX_SDK_ROOTS})
+        set(TEST_OSX_SYSROOT "${SDK_ROOT}/MacOSX${SDK_VERSION}.sdk")
+        if(EXISTS "${TEST_OSX_SYSROOT}")
+          # Retrieve OSX target name
+          string(REPLACE "." "" sdk_version_no_dot ${SDK_VERSION})
+          set(OSX_NAME ${OSX_SDK_${sdk_version_no_dot}_NAME})
+          set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Force build for 64-bit ${OSX_NAME}." FORCE)
+          set(CMAKE_OSX_DEPLOYMENT_TARGET "${SDK_VERSION}" CACHE STRING "Force build for 64-bit ${OSX_NAME}." FORCE)
+          set(CMAKE_OSX_SYSROOT "${TEST_OSX_SYSROOT}" CACHE PATH "Force build for 64-bit ${OSX_NAME}." FORCE)
+          message(STATUS "Setting OSX_ARCHITECTURES to '${CMAKE_OSX_ARCHITECTURES}' as none was specified.")
+          message(STATUS "Setting OSX_DEPLOYMENT_TARGET to '${SDK_VERSION}' as none was specified.")
+          message(STATUS "Setting OSX_SYSROOT to '${TEST_OSX_SYSROOT}' as none was specified.")
+        endif()
+      endforeach()
     endif()
   endforeach()
 
@@ -72,4 +79,7 @@ if(APPLE)
       message(FATAL_ERROR "error: CMAKE_OSX_SYSROOT='${CMAKE_OSX_SYSROOT}' does not exist")
     endif()
   endif()
+  mark_as_advanced( CMAKE_OSX_ARCHITECTURES )
+  mark_as_advanced( CMAKE_OSX_DEPLOYMENT_TARGET )
+  mark_as_advanced( CMAKE_OSX_SYSROOT )
 endif()