summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2010-01-29 16:56:35 (GMT)
committerDavid Cole <david.cole@kitware.com>2010-01-29 16:56:35 (GMT)
commit6ee87b2e5cd31b256c9f1d2f43bd24e665469732 (patch)
tree1383f9961df27fc160e1f0634f6faf96a90dbfc8 /Modules/Platform
parent42c3eb85d62012bad8df85047df70b8fd9bbbeab (diff)
downloadCMake-6ee87b2e5cd31b256c9f1d2f43bd24e665469732.zip
CMake-6ee87b2e5cd31b256c9f1d2f43bd24e665469732.tar.gz
CMake-6ee87b2e5cd31b256c9f1d2f43bd24e665469732.tar.bz2
Fix issue #10155 - default value of CMAKE_OSX_DEPLOYMENT_TARGET should always be the empty string. When the value of CMAKE_OSX_DEPLOYMENT_TARGET is the empty string, the -mmacosx-version-min flag should not show up on the compiler command line. The logic for selecting default value of CMAKE_OSX_SYSROOT is orthogonal to and independent of the value of the deployment target. The default value for CMAKE_OSX_SYSROOT is the SDK that corresponds to the current version of Mac OSX on which cmake is running.
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Darwin-GNU-C.cmake1
-rw-r--r--Modules/Platform/Darwin-GNU-CXX.cmake1
-rw-r--r--Modules/Platform/Darwin-GNU.cmake20
-rw-r--r--Modules/Platform/Darwin.cmake47
4 files changed, 38 insertions, 31 deletions
diff --git a/Modules/Platform/Darwin-GNU-C.cmake b/Modules/Platform/Darwin-GNU-C.cmake
index 155d594..4e326c4 100644
--- a/Modules/Platform/Darwin-GNU-C.cmake
+++ b/Modules/Platform/Darwin-GNU-C.cmake
@@ -1,3 +1,4 @@
include(Platform/Darwin-GNU)
__darwin_compiler_gnu(C)
cmake_gnu_has_isysroot(C)
+cmake_gnu_set_osx_deployment_target_flag(C)
diff --git a/Modules/Platform/Darwin-GNU-CXX.cmake b/Modules/Platform/Darwin-GNU-CXX.cmake
index 6cc0812..b39487e 100644
--- a/Modules/Platform/Darwin-GNU-CXX.cmake
+++ b/Modules/Platform/Darwin-GNU-CXX.cmake
@@ -1,3 +1,4 @@
include(Platform/Darwin-GNU)
__darwin_compiler_gnu(CXX)
cmake_gnu_has_isysroot(CXX)
+cmake_gnu_set_osx_deployment_target_flag(CXX)
diff --git a/Modules/Platform/Darwin-GNU.cmake b/Modules/Platform/Darwin-GNU.cmake
index b528c88..4c2194a 100644
--- a/Modules/Platform/Darwin-GNU.cmake
+++ b/Modules/Platform/Darwin-GNU.cmake
@@ -42,3 +42,23 @@ macro(cmake_gnu_has_isysroot lang)
endif()
endif()
endmacro()
+
+macro(cmake_gnu_set_osx_deployment_target_flag lang)
+ if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
+ set(_doc "${lang} compiler supports OSX deployment target flag")
+ message(STATUS "Checking whether ${_doc}")
+ execute_process(
+ COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
+ OUTPUT_VARIABLE _gcc_help
+ ERROR_VARIABLE _gcc_help
+ )
+ if("${_gcc_help}" MATCHES "macosx-version-min")
+ message(STATUS "Checking whether ${_doc} - yes")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
+ else()
+ message(STATUS "Checking whether ${_doc} - no")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
+ endif()
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "SET(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")")
+ endif()
+endmacro()
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 4aecc1b..c8bcad1 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -78,34 +78,19 @@ EXECUTE_PROCESS(COMMAND sw_vers -productVersion
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)
- STRING(REGEX REPLACE "^.*(10)\\.([0-9]+)\\.*([0-9]+)*.*$" "\\1.\\2"
- CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT ${CURRENT_OSX_VERSION})
-ENDIF(CMAKE_OSX_SYSROOT)
+# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ...
+#
+STRING(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1"
+ _CURRENT_OSX_VERSION "${CURRENT_OSX_VERSION}")
-# 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 "")
+#----------------------------------------------------------------------------
+# CMAKE_OSX_DEPLOYMENT_TARGET
# 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
+IF(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
+ SET(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" 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)
+ENDIF(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
#----------------------------------------------------------------------------
# CMAKE_OSX_SYSROOT
@@ -114,20 +99,20 @@ ENDIF(CURRENT_OSX_VERSION GREATER 10.3)
# Use the same environment variable that Xcode uses.
SET(ENV_SDKROOT "$ENV{SDKROOT}")
-# Set CMAKE_OSX_SYSROOT_DEFAULT based on CMAKE_OSX_DEPLOYMENT_TARGET,
+# Set CMAKE_OSX_SYSROOT_DEFAULT based on _CURRENT_OSX_VERSION,
# accounting for the known specially named SDKs.
SET(CMAKE_OSX_SYSROOT_DEFAULT
- "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}.sdk")
+ "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX${_CURRENT_OSX_VERSION}.sdk")
-IF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.4")
+IF(_CURRENT_OSX_VERSION STREQUAL "10.4")
SET(CMAKE_OSX_SYSROOT_DEFAULT
"${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.4u.sdk")
-ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.4")
+ENDIF(_CURRENT_OSX_VERSION STREQUAL "10.4")
-IF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.3")
+IF(_CURRENT_OSX_VERSION STREQUAL "10.3")
SET(CMAKE_OSX_SYSROOT_DEFAULT
"${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.3.9.sdk")
-ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET EQUAL "10.3")
+ENDIF(_CURRENT_OSX_VERSION STREQUAL "10.3")
# Use environment or default as initial cache value:
IF(NOT ENV_SDKROOT STREQUAL "")
@@ -152,7 +137,7 @@ function(SanityCheckSDKAndDeployTarget _sdk_path _deploy)
string(REGEX REPLACE "(.*MacOSX*)(....)(.*\\.sdk)" "\\2" SDK "${_sdk_path}")
if(_deploy GREATER "${SDK}")
- message(FATAL_ERROR "CMAKE_OSX_DEPLOYMENT_TARGET (${_deploy}) is greater than CMAKE_OSX_SYSROOT SDK (${_sdk_path}). Please set CMAKE_OSX_DEPLOYMENT_TARGET to ${SDK}")
+ message(FATAL_ERROR "CMAKE_OSX_DEPLOYMENT_TARGET (${_deploy}) is greater than CMAKE_OSX_SYSROOT SDK (${_sdk_path}). Please set CMAKE_OSX_DEPLOYMENT_TARGET to ${SDK} or lower")
endif()
endfunction(SanityCheckSDKAndDeployTarget)
#----------------------------------------------------------------------------