Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/platform/platform_apple_xcode.cmake
| Context not available. | |||||
| unset(_xcode_vers_build_nr_single_line) | unset(_xcode_vers_build_nr_single_line) | ||||
| endif() | endif() | ||||
| unset(_xcode_vers_build_nr) | unset(_xcode_vers_build_nr) | ||||
| unset(_xcode_vers_result) | unset(_xcode_vers_result) | ||||
| endif() | endif() | ||||
| if(XCODE_VERSION) | if(XCODE_VERSION) | ||||
| # Construct SDKs path ourselves, because xcode-select path could be ambiguous. | # Construct SDKs path ourselves, because xcode-select path could be ambiguous. | ||||
| # Both /Applications/Xcode.app/Contents/Developer or /Applications/Xcode.app would be allowed. | # Both /Applications/Xcode.app/Contents/Developer or /Applications/Xcode.app would be allowed. | ||||
| set(XCODE_SDK_DIR ${XCODE_DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs) | set(XCODE_SDK_DIR "${XCODE_DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs") | ||||
| # Detect SDK version to use | # Detect SDK version to use | ||||
| if(NOT DEFINED OSX_SYSTEM) | if(NOT DEFINED OSX_SYSTEM) | ||||
| execute_process( | execute_process( | ||||
| COMMAND xcodebuild -version -sdk macosx SDKVersion | COMMAND xcodebuild -version -sdk macosx SDKVersion | ||||
| OUTPUT_VARIABLE OSX_SYSTEM | OUTPUT_VARIABLE OSX_SYSTEM | ||||
| OUTPUT_STRIP_TRAILING_WHITESPACE) | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||||
| endif() | endif() | ||||
| message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_DEVELOPER_DIR}") | message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_DEVELOPER_DIR}") | ||||
| 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 --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(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "" FORCE) | ||||
| set(OSX_SDK_PATH) | if(NOT EXISTS ${CMAKE_OSX_SYSROOT}) | ||||
| set(OSX_SDK_FOUND FALSE) | if($ENV{SDKROOT} OR $ENV{DEVELOPER_DIR}) | ||||
| set(OSX_SDKROOT) | message(WARNING "The environment variables given at `man xcrun` could be interfering with SDK detection.") | ||||
| 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() | endif() | ||||
| endforeach() | |||||
| unset(OSX_SDK_TEST_VERSIONS) | |||||
| if(NOT OSX_SDK_FOUND) | |||||
| message(FATAL_ERROR "Unable to find SDK for macOS version ${OSX_SYSTEM}") | message(FATAL_ERROR "Unable to find SDK for macOS version ${OSX_SYSTEM}") | ||||
| 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. | |||||