llvm.org GIT mirror llvm / f801d8b
cmake: Simplify the iOS.cmake toolchain - Remove a comment that was clearly copy pasted from Android.cmake and isn't relevant. - Remove the toolchain's sensitivity to the environment. It's less error prone to just allow users to set CMAKE_OSX_SYSROOT if they want to use a custom SDK. - Stop explicitly setting -mios-version-min to the default value. It just adds needless complexity. This makes building the native tablegen work for me even when SDKROOT is set in the environment (or passed in as -DCMAKE_OSX_SYSROOT). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260763 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 3 years ago
1 changed file(s) with 15 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
0 # Toolchain config for iOS.
1 #
2 # Usage:
3 # mkdir build; cd build
4 # cmake ..; make
5 # mkdir ios; cd ios
6 # cmake -DLLVM_IOS_TOOLCHAIN_DIR=/path/to/ios/ndk \
7 # -DCMAKE_TOOLCHAIN_FILE=../../cmake/platforms/iOS.cmake ../..
8 # make
91
102 SET(CMAKE_SYSTEM_NAME Darwin)
113 SET(CMAKE_SYSTEM_VERSION 13)
124 SET(CMAKE_CXX_COMPILER_WORKS True)
135 SET(CMAKE_C_COMPILER_WORKS True)
14 SET(DARWIN_TARGET_OS_NAME ios)
156
16 IF(NOT DEFINED ENV{SDKROOT})
17 execute_process(COMMAND xcodebuild -version -sdk iphoneos Path
18 OUTPUT_VARIABLE SDKROOT
19 ERROR_QUIET
20 OUTPUT_STRIP_TRAILING_WHITESPACE)
21 ELSE()
22 execute_process(COMMAND xcodebuild -version -sdk $ENV{SDKROOT} Path
23 OUTPUT_VARIABLE SDKROOT
24 ERROR_QUIET
25 OUTPUT_STRIP_TRAILING_WHITESPACE)
26 ENDIF()
7 if(NOT CMAKE_OSX_SYSROOT)
8 execute_process(COMMAND xcodebuild -version -sdk iphoneos Path
9 OUTPUT_VARIABLE SDKROOT
10 ERROR_QUIET
11 OUTPUT_STRIP_TRAILING_WHITESPACE)
2712
28 IF(NOT EXISTS ${SDKROOT})
29 MESSAGE(FATAL_ERROR "SDKROOT could not be detected!")
30 ENDIF()
13 IF(NOT EXISTS ${SDKROOT})
14 MESSAGE(FATAL_ERROR "SDKROOT could not be detected!")
15 ENDIF()
3116
32 set(CMAKE_OSX_SYSROOT ${SDKROOT})
17 message(STATUS "Using SDKROOT ${SDKROOT}")
18 set(CMAKE_OSX_SYSROOT ${SDKROOT})
19 endif()
3320
3421 IF(NOT CMAKE_C_COMPILER)
35 execute_process(COMMAND xcrun -sdk ${SDKROOT} -find clang
22 execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
3623 OUTPUT_VARIABLE CMAKE_C_COMPILER
3724 ERROR_QUIET
3825 OUTPUT_STRIP_TRAILING_WHITESPACE)
4027 ENDIF()
4128
4229 IF(NOT CMAKE_CXX_COMPILER)
43 execute_process(COMMAND xcrun -sdk ${SDKROOT} -find clang++
30 execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
4431 OUTPUT_VARIABLE CMAKE_CXX_COMPILER
4532 ERROR_QUIET
4633 OUTPUT_STRIP_TRAILING_WHITESPACE)
4835 ENDIF()
4936
5037 IF(NOT CMAKE_AR)
51 execute_process(COMMAND xcrun -sdk ${SDKROOT} -find ar
38 execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ar
5239 OUTPUT_VARIABLE CMAKE_AR_val
5340 ERROR_QUIET
5441 OUTPUT_STRIP_TRAILING_WHITESPACE)
5744 ENDIF()
5845
5946 IF(NOT CMAKE_RANLIB)
60 execute_process(COMMAND xcrun -sdk ${SDKROOT} -find ranlib
47 execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ranlib
6148 OUTPUT_VARIABLE CMAKE_RANLIB_val
6249 ERROR_QUIET
6350 OUTPUT_STRIP_TRAILING_WHITESPACE)
6451 SET(CMAKE_RANLIB ${CMAKE_RANLIB_val} CACHE FILEPATH "Ranlib")
6552 message(STATUS "Using ranlib ${CMAKE_RANLIB}")
6653 ENDIF()
67
68 IF (NOT DEFINED IOS_MIN_TARGET)
69 execute_process(COMMAND xcodebuild -sdk ${SDKROOT} -version SDKVersion
70 OUTPUT_VARIABLE IOS_MIN_TARGET
71 ERROR_QUIET
72 OUTPUT_STRIP_TRAILING_WHITESPACE)
73 ENDIF()
74
75 SET(IOS_COMMON_FLAGS "-mios-version-min=${IOS_MIN_TARGET}")
76 SET(CMAKE_C_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE)
77 SET(CMAKE_CXX_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE)
78 SET(CMAKE_LINK_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_linkflags" FORCE)