Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-03-26 10:57:52 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-03-26 10:59:08 +0300
commitfd262d31960d3a6365856ad373717c1ab2c9df88 (patch)
tree40386c34aa6e0812dd5e41031cc890980a64a612 /build_files
parent09b8cdb25e451cf19c5671feaa9d6cdb297e3ccb (diff)
CMake: Fix detection of Xcode version
Legacy code did not take into account the fact that major version can be two digits. This was causing "Xcode 11.4" to be detected as "11.".
Diffstat (limited to 'build_files')
-rw-r--r--build_files/cmake/platform/platform_apple_xcode.cmake20
1 files changed, 18 insertions, 2 deletions
diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake b/build_files/cmake/platform/platform_apple_xcode.cmake
index e42928328f3..6371bd9b288 100644
--- a/build_files/cmake/platform/platform_apple_xcode.cmake
+++ b/build_files/cmake/platform/platform_apple_xcode.cmake
@@ -68,10 +68,26 @@ if(${CMAKE_GENERATOR} MATCHES "Xcode")
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
message(STATUS "Setting compiler to: " ${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION})
endif()
-else() # unix makefile generator does not fill XCODE_VERSION var, so we get it with a command
+else()
+ # Unix makefile generator does not fill XCODE_VERSION var, so we get it with a command.
+ # 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
+ # former one. Here is an example of the output:
+ # Xcode 11.4
+ # Build version 11E146
+ # The expected XCODE_VERSION in this case is 11.4.
+
execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERS_BUILD_NR)
- string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
+
+ # Convert output to a single line by replacling newlines with spaces.
+ # This is needed because regex replace can not operate through the newline character
+ # and applies substitutions for each individual lines.
+ string(REPLACE "\n" " " XCODE_VERS_BUILD_NR_SINGLE_LINE "${XCODE_VERS_BUILD_NR}")
+
+ string(REGEX REPLACE "(.*)Xcode ([0-9\\.]+).*" "\\2" XCODE_VERSION "${XCODE_VERS_BUILD_NR_SINGLE_LINE}")
+
unset(XCODE_VERS_BUILD_NR)
+ unset(XCODE_VERS_BUILD_NR_SINGLE_LINE)
endif()
message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_BUNDLE}")