llvm.org GIT mirror llvm / 1282ae4
[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 Chris Bieneman 3 years ago
1 changed file(s) with 30 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
3939 return()
4040 endif()
4141
42 # XCODE_VERSION is set by CMake when using the Xcode generator, otherwise we need
43 # to detect it manually here.
44 if(NOT XCODE_VERSION)
45 execute_process(
46 COMMAND xcodebuild -version
47 OUTPUT_VARIABLE xcodebuild_version
48 OUTPUT_STRIP_TRAILING_WHITESPACE
49 ERROR_FILE /dev/null
50 )
51 string(REGEX MATCH "Xcode ([0-9][.][0-9][.][0-9])" version_match ${xcodebuild_version})
52 if(version_match)
53 message(STATUS "Identified Xcode Version: ${CMAKE_MATCH_1}")
54 set(XCODE_VERSION ${CMAKE_MATCH_1})
55 else()
56 # If detecting Xcode version failed, set a crazy high version so we default
57 # to the newest.
58 set(XCODE_VERSION 99)
59 message(WARNING "Failed to detect the version of an installed copy of Xcode, falling back to highest supported version. Set XCODE_VERSION to override.")
60 endif()
61 endif()
62
63 # Xcode 8 requires CompatibilityVersion 2
64 set(COMPAT_VERSION 2)
65 if(XCODE_VERSION VERSION_LESS 8.0.0)
66 # Xcode 7.3 (the first version supporting external toolchains) requires
67 # CompatibilityVersion 1
68 set(COMPAT_VERSION 1)
69 endif()
70
4271 execute_process(
4372 COMMAND xcrun -find otool
4473 OUTPUT_VARIABLE clang_path
6089 DEPENDS ${LLVMToolchainDir}
6190 COMMAND ${CMAKE_COMMAND} -E remove ${LLVMToolchainDir}/Info.plist
6291 COMMAND /usr/libexec/PlistBuddy -c "Add:CFBundleIdentifier string org.llvm.${PACKAGE_VERSION}" "${LLVMToolchainDir}/Info.plist"
63 COMMAND /usr/libexec/PlistBuddy -c "Add:CompatibilityVersion integer 1" "${LLVMToolchainDir}/Info.plist"
92 COMMAND /usr/libexec/PlistBuddy -c "Add:CompatibilityVersion integer ${COMPAT_VERSION}" "${LLVMToolchainDir}/Info.plist"
6493 )
6594
6695 add_custom_target(install-xcode-toolchain