Merge topic 'osx-sysroot-cleanup'
df92864
OS X: Ignore MACOSX_DEPLOYMENT_TARGET during Xcode compiler ide7e613e
OS X: Teach deployment target sanity check about SDK names43b7479
OS X: Further improve default CMAKE_OSX_SYSROOT selection2690738
OS X: If CMAKE_OSX_SYSROOT is already set do not compute default7995722
OS X: Simplify selection of CMAKE_OSX_ARCHITECTURES1786b12
OS X: Allow CMAKE_OSX_SYSROOT to be a logical SDK name242f673
Tests/Assembler: Use CMAKE_OSX_SYSROOT to generate .s filea1c032b
bootstrap: Suppress CMAKE_OSX_SYSROOT if CFLAGS have -isysroot230ea21
OS X: Improve default CMAKE_OSX_SYSROOT selectiona0a0877
OS X: Always generate -isysroot if any SDK is in use33a60e6
Xcode: Remove unused code reading CMAKE_OSX_SYSROOT_DEFAULT
This commit is contained in:
commit
021e66a25c
|
@ -45,7 +45,7 @@ if(CMAKE_C_LIBRARY_ARCHITECTURE)
|
||||||
set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_C_LIBRARY_ARCHITECTURE@")
|
set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_C_LIBRARY_ARCHITECTURE@")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_C_HAS_ISYSROOT "@CMAKE_C_HAS_ISYSROOT@")
|
@CMAKE_C_SYSROOT_FLAG_CODE@
|
||||||
@CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
|
@CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
|
||||||
|
|
||||||
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@")
|
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@")
|
||||||
|
|
|
@ -46,7 +46,7 @@ if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
|
||||||
set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_CXX_LIBRARY_ARCHITECTURE@")
|
set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_CXX_LIBRARY_ARCHITECTURE@")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_HAS_ISYSROOT "@CMAKE_CXX_HAS_ISYSROOT@")
|
@CMAKE_CXX_SYSROOT_FLAG_CODE@
|
||||||
@CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
|
@CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
|
||||||
|
|
||||||
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
|
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
|
||||||
|
|
|
@ -185,12 +185,20 @@ Id flags: ${testflags}
|
||||||
endif()
|
endif()
|
||||||
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in
|
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in
|
||||||
${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY IMMEDIATE)
|
${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY IMMEDIATE)
|
||||||
|
unset(_ENV_MACOSX_DEPLOYMENT_TARGET)
|
||||||
|
if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
|
||||||
|
set(_ENV_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}")
|
||||||
|
set(ENV{MACOSX_DEPLOYMENT_TARGET} "")
|
||||||
|
endif()
|
||||||
execute_process(COMMAND xcodebuild
|
execute_process(COMMAND xcodebuild
|
||||||
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
|
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
|
||||||
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
||||||
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
||||||
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
|
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
|
||||||
)
|
)
|
||||||
|
if(DEFINED _ENV_MACOSX_DEPLOYMENT_TARGET)
|
||||||
|
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${_ENV_MACOSX_DEPLOYMENT_TARGET}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Match the link line from xcodebuild output of the form
|
# Match the link line from xcodebuild output of the form
|
||||||
# Ld ...
|
# Ld ...
|
||||||
|
|
|
@ -53,8 +53,8 @@ include(CMakeDetermineSystem)
|
||||||
|
|
||||||
# short-cut some tests on Darwin, see Darwin-GNU.cmake:
|
# short-cut some tests on Darwin, see Darwin-GNU.cmake:
|
||||||
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU)
|
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU)
|
||||||
set(${CMAKE_${LANGUAGE}_HAS_ISYSROOT} 0 )
|
set(CMAKE_${LANGUAGE}_SYSROOT_FLAG "")
|
||||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
|
set(CMAKE_${LANGUAGE}_OSX_DEPLOYMENT_TARGET_FLAG "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Also load the system specific file, which sets up e.g. the search paths.
|
# Also load the system specific file, which sets up e.g. the search paths.
|
||||||
|
|
|
@ -21,6 +21,6 @@ set(__DARWIN_COMPILER_CLANG 1)
|
||||||
macro(__darwin_compiler_clang lang)
|
macro(__darwin_compiler_clang lang)
|
||||||
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||||
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||||
|
set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
|
||||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
|
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
|
||||||
set(CMAKE_${lang}_HAS_ISYSROOT 1)
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
include(Platform/Darwin-GNU)
|
include(Platform/Darwin-GNU)
|
||||||
__darwin_compiler_gnu(C)
|
__darwin_compiler_gnu(C)
|
||||||
cmake_gnu_has_isysroot(C)
|
cmake_gnu_set_sysroot_flag(C)
|
||||||
cmake_gnu_set_osx_deployment_target_flag(C)
|
cmake_gnu_set_osx_deployment_target_flag(C)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
include(Platform/Darwin-GNU)
|
include(Platform/Darwin-GNU)
|
||||||
__darwin_compiler_gnu(CXX)
|
__darwin_compiler_gnu(CXX)
|
||||||
cmake_gnu_has_isysroot(CXX)
|
cmake_gnu_set_sysroot_flag(CXX)
|
||||||
cmake_gnu_set_osx_deployment_target_flag(CXX)
|
cmake_gnu_set_osx_deployment_target_flag(CXX)
|
||||||
|
|
|
@ -24,8 +24,8 @@ macro(__darwin_compiler_gnu lang)
|
||||||
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(cmake_gnu_has_isysroot lang)
|
macro(cmake_gnu_set_sysroot_flag lang)
|
||||||
if("x${CMAKE_${lang}_HAS_ISYSROOT}" STREQUAL "x")
|
if(NOT DEFINED CMAKE_${lang}_SYSROOT_FLAG)
|
||||||
set(_doc "${lang} compiler has -isysroot")
|
set(_doc "${lang} compiler has -isysroot")
|
||||||
message(STATUS "Checking whether ${_doc}")
|
message(STATUS "Checking whether ${_doc}")
|
||||||
execute_process(
|
execute_process(
|
||||||
|
@ -35,11 +35,12 @@ macro(cmake_gnu_has_isysroot lang)
|
||||||
)
|
)
|
||||||
if("${_gcc_help}" MATCHES "isysroot")
|
if("${_gcc_help}" MATCHES "isysroot")
|
||||||
message(STATUS "Checking whether ${_doc} - yes")
|
message(STATUS "Checking whether ${_doc} - yes")
|
||||||
set(CMAKE_${lang}_HAS_ISYSROOT 1)
|
set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Checking whether ${_doc} - no")
|
message(STATUS "Checking whether ${_doc} - no")
|
||||||
set(CMAKE_${lang}_HAS_ISYSROOT 0)
|
set(CMAKE_${lang}_SYSROOT_FLAG "")
|
||||||
endif()
|
endif()
|
||||||
|
set(CMAKE_${lang}_SYSROOT_FLAG_CODE "set(CMAKE_${lang}_SYSROOT_FLAG \"${CMAKE_${lang}_SYSROOT_FLAG}\")")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
|
@ -59,34 +59,28 @@ if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||||
mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
|
mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set the assumed (Pre 10.5 or Default) location of the developer tools
|
# Ask xcode-select where to find /Developer or fall back to ancient location.
|
||||||
set(OSX_DEVELOPER_ROOT "/Developer")
|
execute_process(COMMAND xcode-select -print-path
|
||||||
|
OUTPUT_VARIABLE _stdout
|
||||||
# Use the xcode-select tool if it's available (Xcode >= 3.0 installations)
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
find_program(CMAKE_XCODE_SELECT xcode-select)
|
ERROR_VARIABLE _stderr
|
||||||
mark_as_advanced(CMAKE_XCODE_SELECT)
|
RESULT_VARIABLE _failed)
|
||||||
if(CMAKE_XCODE_SELECT)
|
if(NOT _failed AND IS_DIRECTORY ${_stdout})
|
||||||
execute_process(COMMAND ${CMAKE_XCODE_SELECT} "-print-path"
|
set(OSX_DEVELOPER_ROOT ${_stdout})
|
||||||
OUTPUT_VARIABLE OSX_DEVELOPER_ROOT
|
elseif(IS_DIRECTORY "/Developer")
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
set(OSX_DEVELOPER_ROOT "/Developer")
|
||||||
endif()
|
else()
|
||||||
|
set(OSX_DEVELOPER_ROOT "")
|
||||||
# Find installed SDKs
|
|
||||||
# Start with Xcode-4.3+ default SDKs directory
|
|
||||||
set(_CMAKE_OSX_SDKS_DIR
|
|
||||||
"${OSX_DEVELOPER_ROOT}/Platforms/MacOSX.platform/Developer/SDKs")
|
|
||||||
file(GLOB _CMAKE_OSX_SDKS "${_CMAKE_OSX_SDKS_DIR}/*")
|
|
||||||
|
|
||||||
# If not present, try pre-4.3 SDKs directory
|
|
||||||
if(NOT _CMAKE_OSX_SDKS)
|
|
||||||
set(_CMAKE_OSX_SDKS_DIR "${OSX_DEVELOPER_ROOT}/SDKs")
|
|
||||||
file(GLOB _CMAKE_OSX_SDKS "${_CMAKE_OSX_SDKS_DIR}/*")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(COMMAND sw_vers -productVersion
|
execute_process(COMMAND sw_vers -productVersion
|
||||||
OUTPUT_VARIABLE CURRENT_OSX_VERSION
|
OUTPUT_VARIABLE CURRENT_OSX_VERSION
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
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, ...
|
# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ...
|
||||||
#
|
#
|
||||||
|
@ -105,79 +99,108 @@ endif()
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# CMAKE_OSX_SYSROOT
|
# CMAKE_OSX_SYSROOT
|
||||||
|
|
||||||
# Environment variable set by the user overrides our default.
|
if(CMAKE_OSX_SYSROOT)
|
||||||
# Use the same environment variable that Xcode uses.
|
# Use the existing value without further computation to choose a default.
|
||||||
set(ENV_SDKROOT "$ENV{SDKROOT}")
|
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_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()
|
||||||
|
|
||||||
# Set CMAKE_OSX_SYSROOT_DEFAULT based on _CURRENT_OSX_VERSION,
|
if(_CMAKE_OSX_SDKS_DIR)
|
||||||
# accounting for the known specially named SDKs.
|
# Select SDK for current OSX version accounting for the known
|
||||||
set(CMAKE_OSX_SYSROOT_DEFAULT
|
# specially named SDKs.
|
||||||
"${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CURRENT_OSX_VERSION}.sdk")
|
set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u")
|
||||||
|
set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9")
|
||||||
if(_CURRENT_OSX_VERSION STREQUAL "10.4")
|
set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}})
|
||||||
set(CMAKE_OSX_SYSROOT_DEFAULT
|
set(_CMAKE_OSX_SYSROOT_DEFAULT
|
||||||
"${_CMAKE_OSX_SDKS_DIR}/MacOSX10.4u.sdk")
|
"${_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).
|
||||||
if(_CURRENT_OSX_VERSION STREQUAL "10.3")
|
set(_CMAKE_OSX_SYSROOT_DEFAULT "")
|
||||||
set(CMAKE_OSX_SYSROOT_DEFAULT
|
endif()
|
||||||
"${_CMAKE_OSX_SDKS_DIR}/MacOSX10.3.9.sdk")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Use environment or default as initial cache value:
|
|
||||||
if(NOT ENV_SDKROOT STREQUAL "")
|
|
||||||
set(CMAKE_OSX_SYSROOT_VALUE ${ENV_SDKROOT})
|
|
||||||
else()
|
|
||||||
set(CMAKE_OSX_SYSROOT_VALUE ${CMAKE_OSX_SYSROOT_DEFAULT})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
|
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
|
||||||
set(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT_VALUE} CACHE PATH
|
# 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.")
|
"The product will be built against the headers and libraries located inside the indicated SDK.")
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
# Transform the cached value to something we can use.
|
||||||
function(SanityCheckSDKAndDeployTarget _sdk_path _deploy)
|
set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}")
|
||||||
if(_deploy STREQUAL "")
|
set(_CMAKE_OSX_SYSROOT_PATH "")
|
||||||
return()
|
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()
|
||||||
|
endif()
|
||||||
if(_sdk_path STREQUAL "")
|
|
||||||
message(FATAL_ERROR "CMAKE_OSX_DEPLOYMENT_TARGET='${_deploy}' but CMAKE_OSX_SYSROOT is empty... - either set CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to empty")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
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} or lower")
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Make sure the combination of SDK and Deployment Target are allowed
|
# Make sure the combination of SDK and Deployment Target are allowed
|
||||||
SanityCheckSDKAndDeployTarget("${CMAKE_OSX_SYSROOT}" "${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||||
|
if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "^.*/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk")
|
||||||
# set _CMAKE_OSX_MACHINE to uname -m
|
set(_sdk_ver "${CMAKE_MATCH_1}")
|
||||||
execute_process(COMMAND uname -m
|
elseif("${_CMAKE_OSX_SYSROOT_ORIG}" MATCHES "^macosx([0-9]+\\.[0-9]+)$")
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
set(_sdk_ver "${CMAKE_MATCH_1}")
|
||||||
OUTPUT_VARIABLE _CMAKE_OSX_MACHINE)
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
# check for Power PC and change to ppc
|
"CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' "
|
||||||
if(_CMAKE_OSX_MACHINE MATCHES "Power")
|
"but CMAKE_OSX_SYSROOT:\n \"${_CMAKE_OSX_SYSROOT_ORIG}\"\n"
|
||||||
set(_CMAKE_OSX_MACHINE ppc)
|
"is not set to a MacOSX SDK with a recognized version. "
|
||||||
|
"Either set CMAKE_OSX_SYSROOT to a valid SDK or set "
|
||||||
|
"CMAKE_OSX_DEPLOYMENT_TARGET to empty.")
|
||||||
|
endif()
|
||||||
|
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER "${_sdk_ver}")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET}) "
|
||||||
|
"is greater than CMAKE_OSX_SYSROOT SDK:\n ${_CMAKE_OSX_SYSROOT_ORIG}\n"
|
||||||
|
"Please set CMAKE_OSX_DEPLOYMENT_TARGET to ${_sdk_ver} or lower.")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# check for environment variable CMAKE_OSX_ARCHITECTURES
|
|
||||||
# if it is set.
|
|
||||||
if(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
|
||||||
set(CMAKE_OSX_ARCHITECTURES_VALUE "$ENV{CMAKE_OSX_ARCHITECTURES}")
|
|
||||||
else()
|
|
||||||
set(CMAKE_OSX_ARCHITECTURES_VALUE "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# now put _CMAKE_OSX_MACHINE into the cache
|
|
||||||
set(CMAKE_OSX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES_VALUE} CACHE STRING
|
|
||||||
"Build architectures for OSX")
|
|
||||||
|
|
||||||
|
|
||||||
if("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
|
if("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
|
||||||
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
|
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
|
||||||
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
|
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
|
||||||
|
|
|
@ -3118,18 +3118,14 @@ void cmGlobalXCodeGenerator
|
||||||
|
|
||||||
const char* sysroot =
|
const char* sysroot =
|
||||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
||||||
const char* sysrootDefault =
|
|
||||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
|
||||||
const char* deploymentTarget =
|
const char* deploymentTarget =
|
||||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
||||||
if(osxArch && sysroot)
|
if(osxArch && sysroot)
|
||||||
{
|
{
|
||||||
bool flagsUsed = false;
|
|
||||||
// recompute this as it may have been changed since enable language
|
// recompute this as it may have been changed since enable language
|
||||||
this->Architectures.clear();
|
this->Architectures.clear();
|
||||||
cmSystemTools::ExpandListArgument(std::string(osxArch),
|
cmSystemTools::ExpandListArgument(std::string(osxArch),
|
||||||
this->Architectures);
|
this->Architectures);
|
||||||
flagsUsed = true;
|
|
||||||
buildSettings->AddAttribute("SDKROOT",
|
buildSettings->AddAttribute("SDKROOT",
|
||||||
this->CreateString(sysroot));
|
this->CreateString(sysroot));
|
||||||
std::string archString;
|
std::string archString;
|
||||||
|
@ -3144,12 +3140,6 @@ void cmGlobalXCodeGenerator
|
||||||
}
|
}
|
||||||
buildSettings->AddAttribute("ARCHS",
|
buildSettings->AddAttribute("ARCHS",
|
||||||
this->CreateString(archString.c_str()));
|
this->CreateString(archString.c_str()));
|
||||||
if(!flagsUsed && sysrootDefault &&
|
|
||||||
strcmp(sysroot, sysrootDefault) != 0)
|
|
||||||
{
|
|
||||||
buildSettings->AddAttribute("SDKROOT",
|
|
||||||
this->CreateString(sysroot));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(deploymentTarget && *deploymentTarget)
|
if(deploymentTarget && *deploymentTarget)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1792,46 +1792,34 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
||||||
{
|
{
|
||||||
std::vector<std::string> archs;
|
std::vector<std::string> archs;
|
||||||
target->GetAppleArchs(config, archs);
|
target->GetAppleArchs(config, archs);
|
||||||
const char* sysroot =
|
const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
||||||
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
if(sysroot && sysroot[0] == '/' && !sysroot[1])
|
||||||
const char* sysrootDefault =
|
{ sysroot = 0; }
|
||||||
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
std::string sysrootFlagVar =
|
||||||
|
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
|
||||||
|
const char* sysrootFlag =
|
||||||
|
this->Makefile->GetDefinition(sysrootFlagVar.c_str());
|
||||||
const char* deploymentTarget =
|
const char* deploymentTarget =
|
||||||
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
||||||
std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT";
|
|
||||||
bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str());
|
|
||||||
std::string deploymentTargetFlagVar =
|
std::string deploymentTargetFlagVar =
|
||||||
std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
|
std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
|
||||||
const char* deploymentTargetFlag =
|
const char* deploymentTargetFlag =
|
||||||
this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str());
|
this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str());
|
||||||
bool flagsUsed = false;
|
if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F'))
|
||||||
if(!archs.empty() && sysroot && lang && (lang[0] =='C' || lang[0] == 'F'))
|
|
||||||
{
|
{
|
||||||
// if there is more than one arch add the -arch and
|
for(std::vector<std::string>::iterator i = archs.begin();
|
||||||
// -isysroot flags, or if there is one arch flag, but
|
i != archs.end(); ++i)
|
||||||
// it is not the default -arch flag for the system, then
|
|
||||||
// add it. Otherwize do not add -arch and -isysroot
|
|
||||||
if(archs[0] != "")
|
|
||||||
{
|
{
|
||||||
for( std::vector<std::string>::iterator i = archs.begin();
|
flags += " -arch ";
|
||||||
i != archs.end(); ++i)
|
flags += *i;
|
||||||
{
|
|
||||||
flags += " -arch ";
|
|
||||||
flags += *i;
|
|
||||||
}
|
|
||||||
if(hasIsysroot)
|
|
||||||
{
|
|
||||||
flags += " -isysroot ";
|
|
||||||
flags += sysroot;
|
|
||||||
}
|
|
||||||
flagsUsed = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!flagsUsed && sysroot && sysrootDefault &&
|
if(sysrootFlag && *sysrootFlag && sysroot && *sysroot)
|
||||||
strcmp(sysroot, sysrootDefault) != 0 && hasIsysroot)
|
|
||||||
{
|
{
|
||||||
flags += " -isysroot ";
|
flags += " ";
|
||||||
|
flags += sysrootFlag;
|
||||||
|
flags += " ";
|
||||||
flags += sysroot;
|
flags += sysroot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND
|
||||||
if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|Clang|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX))
|
if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|Clang|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX))
|
||||||
set(C_FLAGS "${CMAKE_C_FLAGS}")
|
set(C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
separate_arguments(C_FLAGS)
|
separate_arguments(C_FLAGS)
|
||||||
|
if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};")
|
||||||
|
list(APPEND C_FLAGS ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT})
|
||||||
|
endif()
|
||||||
set(SRCS main.s)
|
set(SRCS main.s)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT main.s
|
OUTPUT main.s
|
||||||
|
|
|
@ -1505,6 +1505,14 @@ set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man p
|
||||||
set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
|
set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
|
||||||
' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
|
' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
|
||||||
|
|
||||||
|
# Suppress -isysroot if user-provided flags already have it.
|
||||||
|
if echo "${cmake_c_flags}" | grep isysroot >/dev/null 2>&1 &&
|
||||||
|
echo "${cmake_cxx_flags}" | grep isysroot >/dev/null 2>&1; then
|
||||||
|
echo '
|
||||||
|
set(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE)
|
||||||
|
' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
|
||||||
|
fi
|
||||||
|
|
||||||
# Add configuration settings given as command-line options.
|
# Add configuration settings given as command-line options.
|
||||||
if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
|
if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
|
||||||
echo '
|
echo '
|
||||||
|
|
Loading…
Reference in New Issue