Merge topic 'osx-init-early'
bbc358c3
Merge branch 'master' into osx-init-early0cce556b
Xcode: Use sysroot and deployment target to identify compiler0200d0a9
OS X: Factor a Darwin-Initialize module out of Platform/Darwin416761e3
Add platform-specific initialization step when enabling languages
This commit is contained in:
commit
d41adb440f
|
@ -215,6 +215,17 @@ Id flags: ${testflags}
|
|||
else()
|
||||
set(id_toolset "")
|
||||
endif()
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set(id_deployment_target
|
||||
"MACOSX_DEPLOYMENT_TARGET = \"${CMAKE_OSX_DEPLOYMENT_TARGET}\";")
|
||||
else()
|
||||
set(id_deployment_target "")
|
||||
endif()
|
||||
if(CMAKE_OSX_SYSROOT)
|
||||
set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";")
|
||||
else()
|
||||
set(id_sdkroot "")
|
||||
endif()
|
||||
if(NOT ${XCODE_VERSION} VERSION_LESS 3)
|
||||
set(v 3)
|
||||
set(ext xcodeproj)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#=============================================================================
|
||||
# Copyright 2002-2014 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# This file is included by cmGlobalGenerator::EnableLanguage.
|
||||
# It is included before the compiler has been determined.
|
||||
|
||||
include(Platform/${CMAKE_SYSTEM_NAME}-Initialize OPTIONAL)
|
||||
|
||||
set(CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED 1)
|
|
@ -84,6 +84,8 @@
|
|||
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
|
||||
SYMROOT = .;
|
||||
@id_toolset@
|
||||
@id_deployment_target@
|
||||
@id_sdkroot@
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
# Ask xcode-select where to find /Developer or fall back to ancient location.
|
||||
execute_process(COMMAND xcode-select -print-path
|
||||
OUTPUT_VARIABLE _stdout
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_VARIABLE _stderr
|
||||
RESULT_VARIABLE _failed)
|
||||
if(NOT _failed AND IS_DIRECTORY ${_stdout})
|
||||
set(OSX_DEVELOPER_ROOT ${_stdout})
|
||||
elseif(IS_DIRECTORY "/Developer")
|
||||
set(OSX_DEVELOPER_ROOT "/Developer")
|
||||
else()
|
||||
set(OSX_DEVELOPER_ROOT "")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND sw_vers -productVersion
|
||||
OUTPUT_VARIABLE CURRENT_OSX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Save CMAKE_OSX_ARCHITECTURES from the environment.
|
||||
set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING
|
||||
"Build architectures for OSX")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# _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}")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
|
||||
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
|
||||
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()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# CMAKE_OSX_SYSROOT
|
||||
|
||||
if(CMAKE_OSX_SYSROOT)
|
||||
# Use the existing value without further computation to choose a default.
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${CMAKE_OSX_SYSROOT}")
|
||||
elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND
|
||||
(NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}"))
|
||||
# Use the value of SDKROOT from the environment.
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}")
|
||||
elseif("${CMAKE_GENERATOR}" MATCHES Xcode
|
||||
OR CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
|
||||
OR NOT EXISTS "/usr/include/sys/types.h")
|
||||
# Find installed SDKs in either Xcode-4.3+ or pre-4.3 SDKs directory.
|
||||
set(_CMAKE_OSX_SDKS_DIR "")
|
||||
if(OSX_DEVELOPER_ROOT)
|
||||
foreach(d Platforms/MacOSX.platform/Developer/SDKs SDKs)
|
||||
file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${d}/*)
|
||||
if(_CMAKE_OSX_SDKS)
|
||||
set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${d})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(_CMAKE_OSX_SDKS_DIR)
|
||||
# Select SDK for current OSX version accounting for the known
|
||||
# specially named SDKs.
|
||||
set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u")
|
||||
set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9")
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set(_CMAKE_OSX_SDKS_VER ${CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${CMAKE_OSX_DEPLOYMENT_TARGET}})
|
||||
set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
|
||||
if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}")
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}")
|
||||
else()
|
||||
set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}})
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
|
||||
message(WARNING
|
||||
"CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' "
|
||||
"but the matching SDK does not exist at:\n \"${_CMAKE_OSX_SYSROOT_CHECK}\"\n"
|
||||
"Instead using SDK:\n \"${_CMAKE_OSX_SYSROOT_DEFAULT}\"\n"
|
||||
"matching the host OS X version."
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}})
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
|
||||
endif()
|
||||
else()
|
||||
# Assume developer files are in root (such as Xcode 4.5 command-line tools).
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
|
||||
# Choose the type based on the current value.
|
||||
set(_CMAKE_OSX_SYSROOT_TYPE STRING)
|
||||
foreach(v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT)
|
||||
if("x${${v}}" MATCHES "/")
|
||||
set(_CMAKE_OSX_SYSROOT_TYPE PATH)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE}
|
||||
"The product will be built against the headers and libraries located inside the indicated SDK.")
|
||||
|
||||
# Transform the cached value to something we can use.
|
||||
set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}")
|
||||
set(_CMAKE_OSX_SYSROOT_PATH "")
|
||||
if(CMAKE_OSX_SYSROOT)
|
||||
if("x${CMAKE_OSX_SYSROOT}" MATCHES "/")
|
||||
# This is a path to the SDK. Make sure it exists.
|
||||
if(NOT IS_DIRECTORY "${CMAKE_OSX_SYSROOT}")
|
||||
message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n"
|
||||
"because the directory does not exist.")
|
||||
set(CMAKE_OSX_SYSROOT "")
|
||||
set(_CMAKE_OSX_SYSROOT_ORIG "")
|
||||
endif()
|
||||
set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}")
|
||||
else()
|
||||
# Transform the sdk name into a path.
|
||||
execute_process(
|
||||
COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path
|
||||
OUTPUT_VARIABLE _stdout
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_VARIABLE _stderr
|
||||
RESULT_VARIABLE _failed
|
||||
)
|
||||
if(NOT _failed AND IS_DIRECTORY "${_stdout}")
|
||||
set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}")
|
||||
# For non-Xcode generators use the path.
|
||||
if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
|
@ -64,143 +64,6 @@ if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
|||
mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
|
||||
endif()
|
||||
|
||||
# Ask xcode-select where to find /Developer or fall back to ancient location.
|
||||
execute_process(COMMAND xcode-select -print-path
|
||||
OUTPUT_VARIABLE _stdout
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_VARIABLE _stderr
|
||||
RESULT_VARIABLE _failed)
|
||||
if(NOT _failed AND IS_DIRECTORY ${_stdout})
|
||||
set(OSX_DEVELOPER_ROOT ${_stdout})
|
||||
elseif(IS_DIRECTORY "/Developer")
|
||||
set(OSX_DEVELOPER_ROOT "/Developer")
|
||||
else()
|
||||
set(OSX_DEVELOPER_ROOT "")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND sw_vers -productVersion
|
||||
OUTPUT_VARIABLE CURRENT_OSX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Save CMAKE_OSX_ARCHITECTURES from the environment.
|
||||
set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING
|
||||
"Build architectures for OSX")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# _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}")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
|
||||
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
|
||||
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()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# CMAKE_OSX_SYSROOT
|
||||
|
||||
if(CMAKE_OSX_SYSROOT)
|
||||
# Use the existing value without further computation to choose a default.
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${CMAKE_OSX_SYSROOT}")
|
||||
elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND
|
||||
(NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}"))
|
||||
# Use the value of SDKROOT from the environment.
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}")
|
||||
elseif("${CMAKE_GENERATOR}" MATCHES Xcode
|
||||
OR CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
|
||||
OR NOT EXISTS "/usr/include/sys/types.h")
|
||||
# Find installed SDKs in either Xcode-4.3+ or pre-4.3 SDKs directory.
|
||||
set(_CMAKE_OSX_SDKS_DIR "")
|
||||
if(OSX_DEVELOPER_ROOT)
|
||||
foreach(d Platforms/MacOSX.platform/Developer/SDKs SDKs)
|
||||
file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${d}/*)
|
||||
if(_CMAKE_OSX_SDKS)
|
||||
set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${d})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(_CMAKE_OSX_SDKS_DIR)
|
||||
# Select SDK for current OSX version accounting for the known
|
||||
# specially named SDKs.
|
||||
set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u")
|
||||
set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9")
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set(_CMAKE_OSX_SDKS_VER ${CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${CMAKE_OSX_DEPLOYMENT_TARGET}})
|
||||
set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
|
||||
if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}")
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}")
|
||||
else()
|
||||
set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}})
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
|
||||
message(WARNING
|
||||
"CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' "
|
||||
"but the matching SDK does not exist at:\n \"${_CMAKE_OSX_SYSROOT_CHECK}\"\n"
|
||||
"Instead using SDK:\n \"${_CMAKE_OSX_SYSROOT_DEFAULT}\"\n"
|
||||
"matching the host OS X version."
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}})
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
|
||||
endif()
|
||||
else()
|
||||
# Assume developer files are in root (such as Xcode 4.5 command-line tools).
|
||||
set(_CMAKE_OSX_SYSROOT_DEFAULT "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
|
||||
# Choose the type based on the current value.
|
||||
set(_CMAKE_OSX_SYSROOT_TYPE STRING)
|
||||
foreach(v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT)
|
||||
if("x${${v}}" MATCHES "/")
|
||||
set(_CMAKE_OSX_SYSROOT_TYPE PATH)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE}
|
||||
"The product will be built against the headers and libraries located inside the indicated SDK.")
|
||||
|
||||
# Transform the cached value to something we can use.
|
||||
set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}")
|
||||
set(_CMAKE_OSX_SYSROOT_PATH "")
|
||||
if(CMAKE_OSX_SYSROOT)
|
||||
if("x${CMAKE_OSX_SYSROOT}" MATCHES "/")
|
||||
# This is a path to the SDK. Make sure it exists.
|
||||
if(NOT IS_DIRECTORY "${CMAKE_OSX_SYSROOT}")
|
||||
message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n"
|
||||
"because the directory does not exist.")
|
||||
set(CMAKE_OSX_SYSROOT "")
|
||||
set(_CMAKE_OSX_SYSROOT_ORIG "")
|
||||
endif()
|
||||
set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}")
|
||||
else()
|
||||
# Transform the sdk name into a path.
|
||||
execute_process(
|
||||
COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path
|
||||
OUTPUT_VARIABLE _stdout
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_VARIABLE _stderr
|
||||
RESULT_VARIABLE _failed
|
||||
)
|
||||
if(NOT _failed AND IS_DIRECTORY "${_stdout}")
|
||||
set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}")
|
||||
# For non-Xcode generators use the path.
|
||||
if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Make sure the combination of SDK and Deployment Target are allowed
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk")
|
||||
|
|
|
@ -319,6 +319,9 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
|
|||
// CMakeSystem.cmake - configured file created by
|
||||
// CMakeDetermineSystem.cmake IF CMAKE_SYSTEM_LOADED
|
||||
|
||||
// CMakeSystemSpecificInitialize.cmake
|
||||
// - includes Platform/${CMAKE_SYSTEM_NAME}-Initialize.cmake
|
||||
|
||||
// Next try and enable all languages found in the languages vector
|
||||
//
|
||||
// FOREACH LANG in languages
|
||||
|
@ -443,6 +446,18 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||
fpath += "/CMakeSystem.cmake";
|
||||
mf->ReadListFile(0,fpath.c_str());
|
||||
}
|
||||
|
||||
// **** Load the system specific initialization if not yet loaded
|
||||
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED"))
|
||||
{
|
||||
fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake");
|
||||
if(!mf->ReadListFile(0,fpath.c_str()))
|
||||
{
|
||||
cmSystemTools::Error("Could not find cmake module file: ",
|
||||
fpath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, bool> needTestLanguage;
|
||||
std::map<std::string, bool> needSetLanguageEnabledMaps;
|
||||
// foreach language
|
||||
|
|
Loading…
Reference in New Issue