Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/platform/platform_apple_xcode.cmake
| Context not available. | |||||
| unset( _cltools_pkg_info) | unset( _cltools_pkg_info) | ||||
| unset(__cltools_pkg_info_result) | unset(__cltools_pkg_info_result) | ||||
| endif() | endif() | ||||
| # Require a relatively recent Xcode version. | # Require a relatively recent Xcode version. | ||||
| if(${XCODE_VERSION} VERSION_LESS 10.0) | if(${XCODE_VERSION} VERSION_LESS 10.0) | ||||
| message(FATAL_ERROR "Only Xcode version 10.0 and newer is supported") | message(FATAL_ERROR "Only Xcode version 10.0 and newer is supported") | ||||
| endif() | endif() | ||||
| # Collect list of OSX system versions which will be used to detect path to corresponding SDK. | # SDK detection. | ||||
| # Start with macOS SDK version reported by xcodebuild and include possible extra ones. | execute_process( | ||||
| # | COMMAND xcrun --sdk macosx --show-sdk-path | ||||
| # The reason for need of extra ones is because it's possible that xcodebuild will report | OUTPUT_VARIABLE OSX_SDK_PATH | ||||
| # SDK version in the full manner (aka major.minor.patch), but the actual path will only | OUTPUT_STRIP_TRAILING_WHITESPACE | ||||
| # include major.minor. | ) | ||||
| # | |||||
| # This happens, for example, on macOS Catalina 10.15.4 and Xcode 11.4: xcodebuild on this | |||||
| # system outputs "10.15.4", but the actual SDK path is MacOSX10.15.sdk. | |||||
| # | |||||
| # This should be safe from picking wrong SDK version because (a) xcodebuild reports full semantic | |||||
| # SDK version, so such SDK does exist on the system. And if it doesn't exist with full version | |||||
| # in the path, what SDK is in the major.minor folder then. | |||||
| set(OSX_SDK_TEST_VERSIONS ${OSX_SYSTEM}) | |||||
| if(OSX_SYSTEM MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)") | |||||
| string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1.\\2" OSX_SYSTEM_NO_PATCH "${OSX_SYSTEM}") | |||||
| list(APPEND OSX_SDK_TEST_VERSIONS ${OSX_SYSTEM_NO_PATCH}) | |||||
| unset(OSX_SYSTEM_NO_PATCH) | |||||
| endif() | |||||
| # Loop through all possible versions and pick the first one which resolves to a valid SDK path. | |||||
| set(OSX_SDK_PATH) | |||||
| set(OSX_SDK_FOUND FALSE) | |||||
| set(OSX_SDKROOT) | |||||
| foreach(OSX_SDK_VERSION ${OSX_SDK_TEST_VERSIONS}) | |||||
| set(CURRENT_OSX_SDK_PATH "${XCODE_SDK_DIR}/MacOSX${OSX_SDK_VERSION}.sdk") | |||||
| if(EXISTS ${CURRENT_OSX_SDK_PATH}) | |||||
| set(OSX_SDK_PATH "${CURRENT_OSX_SDK_PATH}") | |||||
| set(OSX_SDKROOT macosx${OSX_SDK_VERSION}) | |||||
| set(OSX_SDK_FOUND TRUE) | |||||
| break() | |||||
| endif() | |||||
| endforeach() | |||||
| unset(OSX_SDK_TEST_VERSIONS) | |||||
| if(NOT OSX_SDK_FOUND) | set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "" FORCE) | ||||
| message(FATAL_ERROR "Unable to find SDK for macOS version ${OSX_SYSTEM}") | if(NOT EXISTS ${CMAKE_OSX_SYSROOT}) | ||||
| message(FATAL_ERROR "Unable to find SDK for macOS version ${OSX_SYSTEM} at ${CMAKE_OSX_SYSROOT}") | |||||
| endif() | endif() | ||||
| message(STATUS "Detected OSX_SYSROOT: ${OSX_SDK_PATH}") | message(STATUS "Detected OSX_SYSROOT: ${CMAKE_OSX_SYSROOT}") | ||||
| set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "" FORCE) | |||||
| unset(OSX_SDK_PATH) | unset(OSX_SDK_PATH) | ||||
| unset(OSX_SDK_FOUND) | |||||
| if(${CMAKE_GENERATOR} MATCHES "Xcode") | |||||
| # to silence sdk not found warning, just overrides CMAKE_OSX_SYSROOT | |||||
| set(CMAKE_XCODE_ATTRIBUTE_SDKROOT ${OSX_SDKROOT}) | |||||
| endif() | |||||
| unset(OSX_SDKROOT) | |||||
| # 10.13 is our min. target, if you use higher sdk, weak linking happens | # 10.13 is our min. target, if you use higher sdk, weak linking happens | ||||
| if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") | if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") | ||||
| set(OSX_MIN_DEPLOYMENT_TARGET 11.00) | set(OSX_MIN_DEPLOYMENT_TARGET 11.00) | ||||
| else() | else() | ||||
| set(OSX_MIN_DEPLOYMENT_TARGET 10.13) | set(OSX_MIN_DEPLOYMENT_TARGET 10.13) | ||||
| endif() | endif() | ||||
| if(CMAKE_OSX_DEPLOYMENT_TARGET) | if(CMAKE_OSX_DEPLOYMENT_TARGET) | ||||
| Context not available. | |||||