Index: Modules/Platform/Darwin.cmake =================================================================== RCS file: /cvsroot/CMake/CMake/Modules/Platform/Darwin.cmake,v retrieving revision 1.49 diff -u -r1.49 Darwin.cmake --- Modules/Platform/Darwin.cmake 19 Aug 2008 18:23:38 -0000 1.49 +++ Modules/Platform/Darwin.cmake 19 Sep 2008 15:03:52 -0000 @@ -47,46 +47,114 @@ SET(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") -# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree +# hack: IF a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree # (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache # and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun) # hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex IF(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) SET(CMAKE_INSTALL_NAME_TOOL install_name_tool) ENDIF(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + +# Set the assumed (Pre 10.5 or Default) location of the developer tools +SET (OSX_DEVELOPER_ROOT "/Developer") # find installed SDKs -FILE(GLOB _CMAKE_OSX_SDKS "/Developer/SDKs/*") -# setup for universal binaries if sysroot exists -IF(_CMAKE_OSX_SDKS) - # find the most recent sdk for the default - LIST(SORT _CMAKE_OSX_SDKS) - LIST(REVERSE _CMAKE_OSX_SDKS) - LIST(GET _CMAKE_OSX_SDKS 0 _CMAKE_OSX_SDKS) - SET(CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS}") - # use the environment variable CMAKE_OSX_SYSROOT if it is set - IF(NOT "$ENV{CMAKE_OSX_SYSROOT}" STREQUAL "") - SET(_CMAKE_OSX_SDKS "$ENV{CMAKE_OSX_SYSROOT}") - ENDIF(NOT "$ENV{CMAKE_OSX_SYSROOT}" STREQUAL "") - SET(CMAKE_OSX_SYSROOT ${_CMAKE_OSX_SDKS} CACHE PATH - "isysroot used for universal binary support") - # set _CMAKE_OSX_MACHINE to umame -m - EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE _CMAKE_OSX_MACHINE) - # check for Power PC and change to ppc - IF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") - SET(_CMAKE_OSX_MACHINE ppc) - ENDIF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") - # set the default based on uname and not the environment variable - # as that is what is used to change it! - SET(CMAKE_OSX_ARCHITECTURES_DEFAULT ${_CMAKE_OSX_MACHINE}) - # check for environment variable CMAKE_OSX_ARCHITECTURES - # if it is set. - IF(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" STREQUAL "") - SET(_CMAKE_OSX_MACHINE "$ENV{CMAKE_OSX_ARCHITECTURES}") - ENDIF(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" STREQUAL "") - # now put _CMAKE_OSX_MACHINE into the cache - SET(CMAKE_OSX_ARCHITECTURES ${_CMAKE_OSX_MACHINE} - CACHE STRING "Build architectures for OSX") -ENDIF(_CMAKE_OSX_SDKS) +FILE(GLOB _CMAKE_OSX_SDKS "${OSX_DEVELOPER_ROOT}/SDKs/*") + +# If nothing is found there, then try locating the dev tools based on the xcode-select tool +IF(NOT _CMAKE_OSX_SDKS) + EXEC_PROGRAM(/usr/bin/xcode-select ARGS "-print-path" OUTPUT_VARIABLE OSX_DEVELOPER_ROOT) + FILE(GLOB _CMAKE_OSX_SDKS "${OSX_DEVELOPER_ROOT}/SDKs/*") +ENDIF(NOT _CMAKE_OSX_SDKS) + +# Find out the current version of OS X and SET the CMAKE_OSX_DEPLOYMENT_TARGET to that version +# unless over ridden by an environment variable +EXEC_PROGRAM(sw_vers ARGS -productVersion OUTPUT_VARIABLE CURRENT_OSX_VERSION) +#MESSAGE(STATUS "CURRENT_OSX_VERSION: ${CURRENT_OSX_VERSION}") +STRING(REGEX REPLACE "(10?)\\.([0-9]+)\\.([0-9]+)" "\\1.\\2" CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT ${CURRENT_OSX_VERSION}) + +# This next line assumes that Apple will start being consistent with +# the naming of the SDKs 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") + +IF (CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT EQUAL "10.4") + SET(CMAKE_OSX_SYSROOT_DEFAULT "${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.4u.sdk") +ENDIF(CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT EQUAL "10.4") + +IF (CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT 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") + +# Get any Environment variables that were SET by the user +# These environment variables are what Xcode uses so those are a good choice rather +# defining new ones. +SET (ENV_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}") +SET (ENV_SDKROOT "$ENV{SDKROOT}") + +#MESSAGE (STATUS "ENV_MACOSX_DEPLOYMENT_TARGET:${ENV_MACOSX_DEPLOYMENT_TARGET}") +#MESSAGE (STATUS "ENV_SDKROOT:${ENV_SDKROOT}") + +# See IF an environment variable needs is SET and over ride the default with the +# environment variables +IF(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "") + SET(CMAKE_OSX_DEPLOYMENT_TARGET ${ENV_MACOSX_DEPLOYMENT_TARGET} CACHE + STRING "Minimum OS X Version to target for deployment.") +ELSE ((NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "")) + SET(CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT} CACHE + STRING "Minimum OS X Version to target for deployment.") +ENDIF(NOT ENV_MACOSX_DEPLOYMENT_TARGET STREQUAL "") + +IF(NOT ENV_SDKROOT STREQUAL "") + SET(CMAKE_OSX_SYSROOT ${ENV_SDKROOT} CACHE PATH + "Maximum supported version to deploy your compiled code.") +ELSE(NOT ENV_SDKROOT STREQUAL "") + SET(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_DEFAULT}" CACHE PATH + "Maximum supported version to deploy your compiled code.") +ENDIF(NOT ENV_SDKROOT STREQUAL "") + +#---------------------------------------------------------------------------- +function(SanityCheckSDKAndDeployTarget _sdk_path _deploy) + STRING (REGEX REPLACE "(.*MacOSX*)(....)(.*\\.sdk)" "\\2" SDK ${_sdk_path} ) + IF (_deploy GREATER SDK) + MESSAGE (FATAL_ERROR "MACOSX_DEPLOYMENT_TARGET (${_deploy}) is greater than SDK (${_sdk_path}). Please SET the MACOSX_DEPLOYMENT_TARGET to ${SDK}") + ENDIF (_deploy GREATER SDK) +endfunction(SanityCheckSDKAndDeployTarget _sdk_path _deploy) +#---------------------------------------------------------------------------- + +# Ensure the values are set using either the default or the env variables +IF (NOT CMAKE_OSX_SYSROOT) + SET (CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT_DEFAULT} ) +ENDIF (NOT CMAKE_OSX_SYSROOT) +IF (NOT CMAKE_OSX_DEPLOYMENT_TARGET) + SET (CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT} ) +ENDIF (NOT CMAKE_OSX_DEPLOYMENT_TARGET) + +# Make sure the combination of SDK and Deployment Target are allowed +SanityCheckSDKAndDeployTarget(${CMAKE_OSX_SYSROOT} ${CMAKE_OSX_DEPLOYMENT_TARGET}) + +#MESSAGE (STATUS "CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT: ${CMAKE_OSX_DEPLOYMENT_TARGET_DEFAULT}") +#MESSAGE (STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}") +#MESSAGE (STATUS "CMAKE_OSX_SYSROOT_DEFAULT: ${CMAKE_OSX_SYSROOT_DEFAULT}") +#MESSAGE (STATUS "CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT}") + +# SET _CMAKE_OSX_MACHINE to umame -m +EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE _CMAKE_OSX_MACHINE) +# check for Power PC and change to ppc +IF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(_CMAKE_OSX_MACHINE ppc) +ENDIF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") +# SET the default based on uname and not the environment variable +# as that is what is used to change it! +SET(CMAKE_OSX_ARCHITECTURES_DEFAULT ${_CMAKE_OSX_MACHINE}) +# check for environment variable CMAKE_OSX_ARCHITECTURES +# IF it is SET. +IF(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" STREQUAL "") + SET(_CMAKE_OSX_MACHINE "$ENV{CMAKE_OSX_ARCHITECTURES}") +ENDIF(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" STREQUAL "") + +# now put _CMAKE_OSX_MACHINE into the cache +SET(CMAKE_OSX_ARCHITECTURES ${_CMAKE_OSX_MACHINE} CACHE STRING "Build architectures for OSX") IF("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$") @@ -143,7 +211,7 @@ SET(CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES /usr/local/include) # default to searching for frameworks first SET(CMAKE_FIND_FRAMEWORK FIRST) -# set up the default search directories for frameworks +# SET up the default search directories for frameworks SET(CMAKE_SYSTEM_FRAMEWORK_PATH ~/Library/Frameworks /Library/Frameworks @@ -152,7 +220,7 @@ # default to searching for application bundles first SET(CMAKE_FIND_APPBUNDLE FIRST) -# set up the default search directories for application bundles +# SET up the default search directories for application bundles SET(CMAKE_SYSTEM_APPBUNDLE_PATH ~/Applications /Applications