Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/platform/platform_apple_xcode.cmake
| Show All 26 Lines | if(NOT CMAKE_OSX_ARCHITECTURES) | ||||
| set(CMAKE_OSX_ARCHITECTURES ${ARCHITECTURE} CACHE STRING | set(CMAKE_OSX_ARCHITECTURES ${ARCHITECTURE} CACHE STRING | ||||
| "Choose the architecture you want to build Blender for: arm64 or x86_64" | "Choose the architecture you want to build Blender for: arm64 or x86_64" | ||||
| FORCE) | FORCE) | ||||
| endif() | endif() | ||||
| # Detect developer directory. Depending on configuration this may be either | # Detect developer directory. Depending on configuration this may be either | ||||
| # an Xcode or Command Line Tools installation. | # an Xcode or Command Line Tools installation. | ||||
| execute_process( | execute_process( | ||||
| COMMAND xcode-select --print-path | COMMAND xcrun xcode-select --print-path | ||||
| OUTPUT_VARIABLE XCODE_DEVELOPER_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | OUTPUT_VARIABLE XCODE_DEVELOPER_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | ||||
| # Detect Xcode version. It is provided by the Xcode generator but not | # Detect Xcode version. It is provided by the Xcode generator but not | ||||
| # Unix Makefiles or Ninja. | # Unix Makefiles or Ninja. | ||||
| if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode") | if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode") | ||||
| # Note that `xcodebuild -version` gives output in two lines: first line will include | # Note that `xcodebuild -version` gives output in two lines: first line will include | ||||
| # Xcode version, second one will include build number. We are only interested in the | # Xcode version, second one will include build number. We are only interested in the | ||||
| # first line. Here is an example of the output: | # first line. Here is an example of the output: | ||||
| # Xcode 11.4 | # Xcode 11.4 | ||||
| # Build version 11E146 | # Build version 11E146 | ||||
| # The expected XCODE_VERSION in this case is 11.4. | # The expected XCODE_VERSION in this case is 11.4. | ||||
| execute_process( | execute_process( | ||||
| COMMAND xcodebuild -version | COMMAND xcrun xcodebuild -version | ||||
| OUTPUT_VARIABLE _xcode_vers_build_nr | OUTPUT_VARIABLE _xcode_vers_build_nr | ||||
| RESULT_VARIABLE _xcode_vers_result | RESULT_VARIABLE _xcode_vers_result | ||||
| ERROR_QUIET) | ERROR_QUIET) | ||||
| if(_xcode_vers_result EQUAL 0) | if(_xcode_vers_result EQUAL 0) | ||||
| # Convert output to a single line by replacing newlines with spaces. | # Convert output to a single line by replacing newlines with spaces. | ||||
| # This is needed because regex replace can not operate through the newline character | # This is needed because regex replace can not operate through the newline character | ||||
| # and applies substitutions for each individual lines. | # and applies substitutions for each individual lines. | ||||
| Show All 9 Lines | |||||
| 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 xcrun 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}") | ||||
| message(STATUS "SDKs Directory: " ${XCODE_SDK_DIR}) | message(STATUS "SDKs Directory: " ${XCODE_SDK_DIR}) | ||||
| else() | else() | ||||
| # If no Xcode version found, try detecting command line tools. | # If no Xcode version found, try detecting command line tools. | ||||
| execute_process( | execute_process( | ||||
| COMMAND pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | COMMAND pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | ||||
brecht: `pkgutil` is not a development tool affected by `xcrun`. | |||||
| OUTPUT_VARIABLE _cltools_pkg_info | OUTPUT_VARIABLE _cltools_pkg_info | ||||
| OUTPUT_STRIP_TRAILING_WHITESPACE | OUTPUT_STRIP_TRAILING_WHITESPACE | ||||
| RESULT_VARIABLE _cltools_pkg_info_result | RESULT_VARIABLE _cltools_pkg_info_result | ||||
| ERROR_QUIET) | ERROR_QUIET) | ||||
| if(_cltools_pkg_info_result EQUAL 0) | if(_cltools_pkg_info_result EQUAL 0) | ||||
| # Extract version. | # Extract version. | ||||
| string(REGEX REPLACE ".*version: ([0-9]+)\\.([0-9]+).*" "\\1.\\2" XCODE_VERSION "${_cltools_pkg_info}") | string(REGEX REPLACE ".*version: ([0-9]+)\\.([0-9]+).*" "\\1.\\2" XCODE_VERSION "${_cltools_pkg_info}") | ||||
| ▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines | |||||
pkgutil is not a development tool affected by xcrun.