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@")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_HAS_ISYSROOT "@CMAKE_C_HAS_ISYSROOT@")
|
||||
@CMAKE_C_SYSROOT_FLAG_CODE@
|
||||
@CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
|
||||
|
||||
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@")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_HAS_ISYSROOT "@CMAKE_CXX_HAS_ISYSROOT@")
|
||||
@CMAKE_CXX_SYSROOT_FLAG_CODE@
|
||||
@CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
|
||||
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
|
||||
|
|
|
@ -185,12 +185,20 @@ Id flags: ${testflags}
|
|||
endif()
|
||||
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in
|
||||
${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
|
||||
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
|
||||
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
||||
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
||||
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
|
||||
# Ld ...
|
||||
|
|
|
@ -53,8 +53,8 @@ include(CMakeDetermineSystem)
|
|||
|
||||
# short-cut some tests on Darwin, see Darwin-GNU.cmake:
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU)
|
||||
set(${CMAKE_${LANGUAGE}_HAS_ISYSROOT} 0 )
|
||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
|
||||
set(CMAKE_${LANGUAGE}_SYSROOT_FLAG "")
|
||||
set(CMAKE_${LANGUAGE}_OSX_DEPLOYMENT_TARGET_FLAG "")
|
||||
endif()
|
||||
|
||||
# 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)
|
||||
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_${lang}_SYSROOT_FLAG "-isysroot")
|
||||
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
|
||||
set(CMAKE_${lang}_HAS_ISYSROOT 1)
|
||||
endmacro()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
include(Platform/Darwin-GNU)
|
||||
__darwin_compiler_gnu(C)
|
||||
cmake_gnu_has_isysroot(C)
|
||||
cmake_gnu_set_sysroot_flag(C)
|
||||
cmake_gnu_set_osx_deployment_target_flag(C)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
include(Platform/Darwin-GNU)
|
||||
__darwin_compiler_gnu(CXX)
|
||||
cmake_gnu_has_isysroot(CXX)
|
||||
cmake_gnu_set_sysroot_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")
|
||||
endmacro()
|
||||
|
||||
macro(cmake_gnu_has_isysroot lang)
|
||||
if("x${CMAKE_${lang}_HAS_ISYSROOT}" STREQUAL "x")
|
||||
macro(cmake_gnu_set_sysroot_flag lang)
|
||||
if(NOT DEFINED CMAKE_${lang}_SYSROOT_FLAG)
|
||||
set(_doc "${lang} compiler has -isysroot")
|
||||
message(STATUS "Checking whether ${_doc}")
|
||||
execute_process(
|
||||
|
@ -35,11 +35,12 @@ macro(cmake_gnu_has_isysroot lang)
|
|||
)
|
||||
if("${_gcc_help}" MATCHES "isysroot")
|
||||
message(STATUS "Checking whether ${_doc} - yes")
|
||||
set(CMAKE_${lang}_HAS_ISYSROOT 1)
|
||||
set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
|
||||
else()
|
||||
message(STATUS "Checking whether ${_doc} - no")
|
||||
set(CMAKE_${lang}_HAS_ISYSROOT 0)
|
||||
set(CMAKE_${lang}_SYSROOT_FLAG "")
|
||||
endif()
|
||||
set(CMAKE_${lang}_SYSROOT_FLAG_CODE "set(CMAKE_${lang}_SYSROOT_FLAG \"${CMAKE_${lang}_SYSROOT_FLAG}\")")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
|
|
@ -59,34 +59,28 @@ if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
|||
mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
|
||||
endif()
|
||||
|
||||
# Set the assumed (Pre 10.5 or Default) location of the developer tools
|
||||
set(OSX_DEVELOPER_ROOT "/Developer")
|
||||
|
||||
# Use the xcode-select tool if it's available (Xcode >= 3.0 installations)
|
||||
find_program(CMAKE_XCODE_SELECT xcode-select)
|
||||
mark_as_advanced(CMAKE_XCODE_SELECT)
|
||||
if(CMAKE_XCODE_SELECT)
|
||||
execute_process(COMMAND ${CMAKE_XCODE_SELECT} "-print-path"
|
||||
OUTPUT_VARIABLE OSX_DEVELOPER_ROOT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
# 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}/*")
|
||||
# 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, ...
|
||||
#
|
||||
|
@ -105,79 +99,108 @@ endif()
|
|||
#----------------------------------------------------------------------------
|
||||
# CMAKE_OSX_SYSROOT
|
||||
|
||||
# Environment variable set by the user overrides our default.
|
||||
# Use the same environment variable that Xcode uses.
|
||||
set(ENV_SDKROOT "$ENV{SDKROOT}")
|
||||
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_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,
|
||||
# accounting for the known specially named SDKs.
|
||||
set(CMAKE_OSX_SYSROOT_DEFAULT
|
||||
"${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CURRENT_OSX_VERSION}.sdk")
|
||||
|
||||
if(_CURRENT_OSX_VERSION STREQUAL "10.4")
|
||||
set(CMAKE_OSX_SYSROOT_DEFAULT
|
||||
"${_CMAKE_OSX_SDKS_DIR}/MacOSX10.4u.sdk")
|
||||
endif()
|
||||
|
||||
if(_CURRENT_OSX_VERSION STREQUAL "10.3")
|
||||
set(CMAKE_OSX_SYSROOT_DEFAULT
|
||||
"${_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})
|
||||
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")
|
||||
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")
|
||||
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.
|
||||
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.")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
function(SanityCheckSDKAndDeployTarget _sdk_path _deploy)
|
||||
if(_deploy STREQUAL "")
|
||||
return()
|
||||
# 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()
|
||||
|
||||
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()
|
||||
#----------------------------------------------------------------------------
|
||||
endif()
|
||||
|
||||
# Make sure the combination of SDK and Deployment Target are allowed
|
||||
SanityCheckSDKAndDeployTarget("${CMAKE_OSX_SYSROOT}" "${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
|
||||
# set _CMAKE_OSX_MACHINE to uname -m
|
||||
execute_process(COMMAND uname -m
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
OUTPUT_VARIABLE _CMAKE_OSX_MACHINE)
|
||||
|
||||
# check for Power PC and change to ppc
|
||||
if(_CMAKE_OSX_MACHINE MATCHES "Power")
|
||||
set(_CMAKE_OSX_MACHINE ppc)
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "^.*/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk")
|
||||
set(_sdk_ver "${CMAKE_MATCH_1}")
|
||||
elseif("${_CMAKE_OSX_SYSROOT_ORIG}" MATCHES "^macosx([0-9]+\\.[0-9]+)$")
|
||||
set(_sdk_ver "${CMAKE_MATCH_1}")
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
"CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' "
|
||||
"but CMAKE_OSX_SYSROOT:\n \"${_CMAKE_OSX_SYSROOT_ORIG}\"\n"
|
||||
"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()
|
||||
|
||||
# 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]$")
|
||||
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
|
||||
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
|
||||
|
|
|
@ -3118,18 +3118,14 @@ void cmGlobalXCodeGenerator
|
|||
|
||||
const char* sysroot =
|
||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
||||
const char* sysrootDefault =
|
||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
||||
const char* deploymentTarget =
|
||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
||||
if(osxArch && sysroot)
|
||||
{
|
||||
bool flagsUsed = false;
|
||||
// recompute this as it may have been changed since enable language
|
||||
this->Architectures.clear();
|
||||
cmSystemTools::ExpandListArgument(std::string(osxArch),
|
||||
this->Architectures);
|
||||
flagsUsed = true;
|
||||
buildSettings->AddAttribute("SDKROOT",
|
||||
this->CreateString(sysroot));
|
||||
std::string archString;
|
||||
|
@ -3144,12 +3140,6 @@ void cmGlobalXCodeGenerator
|
|||
}
|
||||
buildSettings->AddAttribute("ARCHS",
|
||||
this->CreateString(archString.c_str()));
|
||||
if(!flagsUsed && sysrootDefault &&
|
||||
strcmp(sysroot, sysrootDefault) != 0)
|
||||
{
|
||||
buildSettings->AddAttribute("SDKROOT",
|
||||
this->CreateString(sysroot));
|
||||
}
|
||||
}
|
||||
if(deploymentTarget && *deploymentTarget)
|
||||
{
|
||||
|
|
|
@ -1792,46 +1792,34 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
|||
{
|
||||
std::vector<std::string> archs;
|
||||
target->GetAppleArchs(config, archs);
|
||||
const char* sysroot =
|
||||
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
||||
const char* sysrootDefault =
|
||||
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
||||
const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
||||
if(sysroot && sysroot[0] == '/' && !sysroot[1])
|
||||
{ sysroot = 0; }
|
||||
std::string sysrootFlagVar =
|
||||
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
|
||||
const char* sysrootFlag =
|
||||
this->Makefile->GetDefinition(sysrootFlagVar.c_str());
|
||||
const char* deploymentTarget =
|
||||
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("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
|
||||
const char* deploymentTargetFlag =
|
||||
this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str());
|
||||
bool flagsUsed = false;
|
||||
if(!archs.empty() && sysroot && lang && (lang[0] =='C' || lang[0] == 'F'))
|
||||
if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F'))
|
||||
{
|
||||
// if there is more than one arch add the -arch and
|
||||
// -isysroot flags, or if there is one arch flag, but
|
||||
// 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();
|
||||
i != archs.end(); ++i)
|
||||
{
|
||||
for( std::vector<std::string>::iterator i = archs.begin();
|
||||
i != archs.end(); ++i)
|
||||
{
|
||||
flags += " -arch ";
|
||||
flags += *i;
|
||||
}
|
||||
if(hasIsysroot)
|
||||
{
|
||||
flags += " -isysroot ";
|
||||
flags += sysroot;
|
||||
}
|
||||
flagsUsed = true;
|
||||
flags += " -arch ";
|
||||
flags += *i;
|
||||
}
|
||||
}
|
||||
|
||||
if(!flagsUsed && sysroot && sysrootDefault &&
|
||||
strcmp(sysroot, sysrootDefault) != 0 && hasIsysroot)
|
||||
if(sysrootFlag && *sysrootFlag && sysroot && *sysroot)
|
||||
{
|
||||
flags += " -isysroot ";
|
||||
flags += " ";
|
||||
flags += sysrootFlag;
|
||||
flags += " ";
|
||||
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))
|
||||
set(C_FLAGS "${CMAKE_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)
|
||||
add_custom_command(
|
||||
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)
|
||||
' > "${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.
|
||||
if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
|
||||
echo '
|
||||
|
|
Loading…
Reference in New Issue