mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 02:39:48 -06:00
macOS: Avoid relying on sw_vers when cross-compiling from another OS
We have a few code paths needed only to support builds hosted on macOS 10.4. Update the conditions to work when cross-compiling to macOS from another platform. Fixes: #26814
This commit is contained in:
@@ -15,9 +15,11 @@ else()
|
||||
set(OSX_DEVELOPER_ROOT "")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND sw_vers -productVersion
|
||||
OUTPUT_VARIABLE CURRENT_OSX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
execute_process(COMMAND sw_vers -productVersion
|
||||
OUTPUT_VARIABLE _CMAKE_HOST_OSX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
# Save CMAKE_OSX_ARCHITECTURES from the environment.
|
||||
set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING
|
||||
@@ -47,12 +49,6 @@ endif()
|
||||
# Platform/Apple-${CMAKE_CXX_COMPILER_ID}-<LANG>
|
||||
set(CMAKE_EFFECTIVE_SYSTEM_NAME "Apple")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# _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
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ set(CMAKE_APPLE_IMPORT_FILE_PREFIX "lib")
|
||||
set(CMAKE_APPLE_IMPORT_FILE_SUFFIX ".tbd")
|
||||
set(CMAKE_MODULE_EXISTS 1)
|
||||
set(CMAKE_DL_LIBS "")
|
||||
if(NOT "${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
|
||||
if(NOT (DEFINED _CMAKE_HOST_OSX_VERSION AND _CMAKE_HOST_OSX_VERSION VERSION_LESS "10.5"))
|
||||
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
|
||||
endif()
|
||||
|
||||
@@ -80,7 +80,7 @@ endif()
|
||||
# Enable shared library versioning.
|
||||
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
|
||||
|
||||
if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
|
||||
if(DEFINED _CMAKE_HOST_OSX_VERSION AND _CMAKE_HOST_OSX_VERSION VERSION_LESS "10.5")
|
||||
# Need to list dependent shared libraries on link line. When building
|
||||
# with -isysroot (for universal binaries), the linker always looks for
|
||||
# dependent libraries under the sysroot. Listing them on the link
|
||||
@@ -157,7 +157,8 @@ if(_CMAKE_OSX_SYSROOT_PATH)
|
||||
list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
|
||||
/System/Library/Frameworks)
|
||||
endif()
|
||||
if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
|
||||
|
||||
if(DEFINED _CMAKE_HOST_OSX_VERSION AND _CMAKE_HOST_OSX_VERSION VERSION_LESS "10.5")
|
||||
# Older OS X tools had more implicit paths.
|
||||
list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
|
||||
${_CMAKE_OSX_SYSROOT_PATH}/Network/Library/Frameworks)
|
||||
|
||||
Reference in New Issue
Block a user