• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Toolchain config for iOS.
2
3SET(CMAKE_SYSTEM_NAME Darwin)
4SET(CMAKE_SYSTEM_VERSION 13)
5SET(CMAKE_CXX_COMPILER_WORKS True)
6SET(CMAKE_C_COMPILER_WORKS True)
7
8if(NOT CMAKE_OSX_SYSROOT)
9  execute_process(COMMAND xcodebuild -version -sdk iphoneos Path
10    OUTPUT_VARIABLE SDKROOT
11    ERROR_QUIET
12    OUTPUT_STRIP_TRAILING_WHITESPACE)
13
14  IF(NOT EXISTS ${SDKROOT})
15    MESSAGE(FATAL_ERROR "SDKROOT could not be detected!")
16  ENDIF()
17
18  message(STATUS "Using SDKROOT ${SDKROOT}")
19  set(CMAKE_OSX_SYSROOT ${SDKROOT})
20endif()
21
22IF(NOT CMAKE_C_COMPILER)
23  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
24   OUTPUT_VARIABLE CMAKE_C_COMPILER
25   ERROR_QUIET
26   OUTPUT_STRIP_TRAILING_WHITESPACE)
27  message(STATUS "Using c compiler ${CMAKE_C_COMPILER}")
28ENDIF()
29
30IF(NOT CMAKE_CXX_COMPILER)
31  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
32   OUTPUT_VARIABLE CMAKE_CXX_COMPILER
33   ERROR_QUIET
34   OUTPUT_STRIP_TRAILING_WHITESPACE)
35  message(STATUS "Using c compiler ${CMAKE_CXX_COMPILER}")
36ENDIF()
37
38IF(NOT CMAKE_AR)
39  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ar
40   OUTPUT_VARIABLE CMAKE_AR_val
41   ERROR_QUIET
42   OUTPUT_STRIP_TRAILING_WHITESPACE)
43  SET(CMAKE_AR ${CMAKE_AR_val} CACHE FILEPATH "Archiver")
44  message(STATUS "Using ar ${CMAKE_AR}")
45ENDIF()
46
47IF(NOT CMAKE_RANLIB)
48  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ranlib
49   OUTPUT_VARIABLE CMAKE_RANLIB_val
50   ERROR_QUIET
51   OUTPUT_STRIP_TRAILING_WHITESPACE)
52  SET(CMAKE_RANLIB ${CMAKE_RANLIB_val} CACHE FILEPATH "Ranlib")
53  message(STATUS "Using ranlib ${CMAKE_RANLIB}")
54ENDIF()
55