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
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