diff options
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/xcode-toolchain/CMakeLists.txt | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/llvm/tools/xcode-toolchain/CMakeLists.txt b/llvm/tools/xcode-toolchain/CMakeLists.txt index c685dc527e7..d59f7e329e5 100644 --- a/llvm/tools/xcode-toolchain/CMakeLists.txt +++ b/llvm/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 |