summaryrefslogtreecommitdiff
path: root/tools/xcode-toolchain
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-08-18 21:32:48 +0000
committerChris Bieneman <beanz@apple.com>2016-08-18 21:32:48 +0000
commit1282ae48c83756cb4cc05a445bdedd85e2c4d145 (patch)
tree7e354d832cb88284310b7bc165b21de73ba5d805 /tools/xcode-toolchain
parentc5ef0e6004fd8ae09d0f9a8e7b7761d9adde5a3a (diff)
[CMake] Support for generating Xcode 8 compatible toolchains
Xcode 8 requires toolchain compatibility version 2. This allows us to select the correct compatibility version based on the installed version of Xcode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279152 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/xcode-toolchain')
-rw-r--r--tools/xcode-toolchain/CMakeLists.txt31
1 files changed, 30 insertions, 1 deletions
diff --git a/tools/xcode-toolchain/CMakeLists.txt b/tools/xcode-toolchain/CMakeLists.txt
index c685dc527e7..d59f7e329e5 100644
--- a/tools/xcode-toolchain/CMakeLists.txt
+++ b/tools/xcode-toolchain/CMakeLists.txt
@@ -40,6 +40,35 @@ if(NOT LLVM_CREATE_XCODE_TOOLCHAIN)
return()
endif()
+# XCODE_VERSION is set by CMake when using the Xcode generator, otherwise we need
+# to detect it manually here.
+if(NOT XCODE_VERSION)
+ execute_process(
+ COMMAND xcodebuild -version
+ OUTPUT_VARIABLE xcodebuild_version
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_FILE /dev/null
+ )
+ string(REGEX MATCH "Xcode ([0-9][.][0-9][.][0-9])" version_match ${xcodebuild_version})
+ if(version_match)
+ message(STATUS "Identified Xcode Version: ${CMAKE_MATCH_1}")
+ set(XCODE_VERSION ${CMAKE_MATCH_1})
+ else()
+ # If detecting Xcode version failed, set a crazy high version so we default
+ # to the newest.
+ set(XCODE_VERSION 99)
+ message(WARNING "Failed to detect the version of an installed copy of Xcode, falling back to highest supported version. Set XCODE_VERSION to override.")
+ endif()
+endif()
+
+# Xcode 8 requires CompatibilityVersion 2
+set(COMPAT_VERSION 2)
+if(XCODE_VERSION VERSION_LESS 8.0.0)
+ # Xcode 7.3 (the first version supporting external toolchains) requires
+ # CompatibilityVersion 1
+ set(COMPAT_VERSION 1)
+endif()
+
execute_process(
COMMAND xcrun -find otool
OUTPUT_VARIABLE clang_path
@@ -61,7 +90,7 @@ add_custom_command(OUTPUT ${LLVMToolchainDir}/Info.plist
DEPENDS ${LLVMToolchainDir}
COMMAND ${CMAKE_COMMAND} -E remove ${LLVMToolchainDir}/Info.plist
COMMAND /usr/libexec/PlistBuddy -c "Add:CFBundleIdentifier string org.llvm.${PACKAGE_VERSION}" "${LLVMToolchainDir}/Info.plist"
- COMMAND /usr/libexec/PlistBuddy -c "Add:CompatibilityVersion integer 1" "${LLVMToolchainDir}/Info.plist"
+ COMMAND /usr/libexec/PlistBuddy -c "Add:CompatibilityVersion integer ${COMPAT_VERSION}" "${LLVMToolchainDir}/Info.plist"
)
add_custom_target(install-xcode-toolchain