summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/Darwin.cmake
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2009-12-23 17:08:25 (GMT)
committerDavid Cole <david.cole@kitware.com>2009-12-23 17:08:25 (GMT)
commit8d88de4b4ab3bb5b42492cebd827fab124f2f048 (patch)
tree28c74578cee04c7367a8893c6d03479a0e932069 /Modules/Platform/Darwin.cmake
parentffbae660cd841dc9fed8a13b13b75a01506a7dea (diff)
downloadCMake-8d88de4b4ab3bb5b42492cebd827fab124f2f048.zip
CMake-8d88de4b4ab3bb5b42492cebd827fab124f2f048.tar.gz
CMake-8d88de4b4ab3bb5b42492cebd827fab124f2f048.tar.bz2
Fix issue with SDK not matching initial deployment target chosen by setting the MACOSX_DEPLOYMENT_TARGET environment variable. The problem was that we were setting the initial SDK value based on our own internal default value for deplyment target rather than the user's environment variable choice. The solution is to base the default value for the SDK on the deployment target variable after initially caching the deployment target... Every time I'm in this code I think I leave it cleaner, only to be proven otherwise. Let's give this one a whirl. Bleh.
Diffstat (limited to 'Modules/Platform/Darwin.cmake')
-rw-r--r--Modules/Platform/Darwin.cmake68
1 files changed, 37 insertions, 31 deletions
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 2877daf..4aecc1b 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -77,10 +77,16 @@ EXECUTE_PROCESS(COMMAND sw_vers -productVersion
OUTPUT_VARIABLE CURRENT_OSX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
+#----------------------------------------------------------------------------
+# CMAKE_OSX_DEPLOYMENT_TARGET
+
+# Environment variable set by the user overrides our default.
+# Use the same environment variable that Xcode uses.
+SET(ENV_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}")
+
# Set CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT - if user has already specified an SDK
# with CMAKE_OSX_SYSROOT, then deployment target should default to "", otherwise,
# default it to the current OSX version.
-#
IF(CMAKE_OSX_SYSROOT)
SET(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT "")
ELSE(CMAKE_OSX_SYSROOT)
@@ -88,49 +94,49 @@ ELSE(CMAKE_OSX_SYSROOT)
CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT ${CURRENT_OSX_VERSION})
ENDIF(CMAKE_OSX_SYSROOT)
-# Set CMAKE_OSX_SYSROOT_DEFAULT based on CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT.
-# This next block assumes that Apple will start being consistent with
-# its SDK names from here on out...
-IF(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT GREATER "10.4")
- SET(CMAKE_OSX_SYSROOT_DEFAULT
- "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT}.sdk")
-ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT GREATER "10.4")
+# Use environment or default as initial cache value:
+IF(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "")
+ SET(CMAKE_OSX_DEPLOYMENT_TARGET_VALUE ${ENV_MACOSX_DEPLOYMENT_TARGET})
+ELSE(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "")
+ SET(CMAKE_OSX_DEPLOYMENT_TARGET_VALUE ${CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT})
+ENDIF(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "")
+
+# Set cache variable - end user may change this during ccmake or cmake-gui configure.
+IF(CURRENT_OSX_VERSION GREATER 10.3)
+ SET(CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET_VALUE} CACHE STRING
+ "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
+ENDIF(CURRENT_OSX_VERSION GREATER 10.3)
+
+#----------------------------------------------------------------------------
+# CMAKE_OSX_SYSROOT
-IF(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT EQUAL "10.4")
+# Environment variable set by the user overrides our default.
+# Use the same environment variable that Xcode uses.
+SET(ENV_SDKROOT "$ENV{SDKROOT}")
+
+# Set CMAKE_OSX_SYSROOT_DEFAULT based on CMAKE_OSX_DEPLOYMENT_TARGET,
+# accounting for the known specially named SDKs.
+SET(CMAKE_OSX_SYSROOT_DEFAULT
+ "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}.sdk")
+
+IF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.4")
SET(CMAKE_OSX_SYSROOT_DEFAULT
"${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.4u.sdk")
-ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT EQUAL "10.4")
+ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.4")
-IF(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT EQUAL "10.3")
+IF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.3")
SET(CMAKE_OSX_SYSROOT_DEFAULT
"${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.3.9.sdk")
-ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT EQUAL "10.3")
-
-# Allow environment variables set by the user to override our defaults.
-# Use the same environment variables that Xcode uses.
-SET(ENV_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}")
-SET(ENV_SDKROOT "$ENV{SDKROOT}")
-
-# See if we need to override the default SDK or Deployment target with the
-# environment variables
-IF(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "")
- SET(CMAKE_OSX_DEPLOYMENT_TARGET_VALUE ${ENV_MACOSX_DEPLOYMENT_TARGET})
-ELSE(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "")
- SET(CMAKE_OSX_DEPLOYMENT_TARGET_VALUE ${CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT})
-ENDIF(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "")
+ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.3")
+# Use environment or default as initial cache value:
IF(NOT ENV_SDKROOT STREQUAL "")
SET(CMAKE_OSX_SYSROOT_VALUE ${ENV_SDKROOT})
ELSE(NOT ENV_SDKROOT STREQUAL "")
SET(CMAKE_OSX_SYSROOT_VALUE ${CMAKE_OSX_SYSROOT_DEFAULT})
ENDIF(NOT ENV_SDKROOT STREQUAL "")
-# Set cache variables - end user may change these during ccmake or cmake-gui configure.
-IF(CURRENT_OSX_VERSION GREATER 10.3)
- SET(CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET_VALUE} CACHE STRING
- "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
-ENDIF(CURRENT_OSX_VERSION GREATER 10.3)
-
+# Set cache variable - end user may change this during ccmake or cmake-gui configure.
SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT_VALUE} CACHE PATH
"The product will be built against the headers and libraries located inside the indicated SDK.")