• 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)
7SET(IOS True)
8
9if(NOT CMAKE_OSX_SYSROOT)
10  execute_process(COMMAND xcodebuild -version -sdk iphoneos Path
11    OUTPUT_VARIABLE SDKROOT
12    ERROR_QUIET
13    OUTPUT_STRIP_TRAILING_WHITESPACE)
14
15  IF(NOT EXISTS ${SDKROOT})
16    MESSAGE(FATAL_ERROR "SDKROOT could not be detected!")
17  ENDIF()
18
19  message(STATUS "Using SDKROOT ${SDKROOT}")
20  set(CMAKE_OSX_SYSROOT ${SDKROOT})
21endif()
22
23IF(NOT CMAKE_C_COMPILER)
24  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
25   OUTPUT_VARIABLE CMAKE_C_COMPILER
26   ERROR_QUIET
27   OUTPUT_STRIP_TRAILING_WHITESPACE)
28  message(STATUS "Using C compiler ${CMAKE_C_COMPILER}")
29ENDIF()
30
31IF(NOT CMAKE_CXX_COMPILER)
32  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
33   OUTPUT_VARIABLE CMAKE_CXX_COMPILER
34   ERROR_QUIET
35   OUTPUT_STRIP_TRAILING_WHITESPACE)
36  message(STATUS "Using C++ compiler ${CMAKE_CXX_COMPILER}")
37ENDIF()
38
39IF(NOT CMAKE_AR)
40  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ar
41   OUTPUT_VARIABLE CMAKE_AR_val
42   ERROR_QUIET
43   OUTPUT_STRIP_TRAILING_WHITESPACE)
44  SET(CMAKE_AR ${CMAKE_AR_val} CACHE FILEPATH "Archiver")
45  message(STATUS "Using ar ${CMAKE_AR}")
46ENDIF()
47
48IF(NOT CMAKE_RANLIB)
49  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find ranlib
50   OUTPUT_VARIABLE CMAKE_RANLIB_val
51   ERROR_QUIET
52   OUTPUT_STRIP_TRAILING_WHITESPACE)
53  SET(CMAKE_RANLIB ${CMAKE_RANLIB_val} CACHE FILEPATH "Ranlib")
54  message(STATUS "Using ranlib ${CMAKE_RANLIB}")
55ENDIF()
56
57IF(NOT CMAKE_STRIP)
58  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find strip
59   OUTPUT_VARIABLE CMAKE_STRIP_val
60   ERROR_QUIET
61   OUTPUT_STRIP_TRAILING_WHITESPACE)
62  SET(CMAKE_STRIP ${CMAKE_STRIP_val} CACHE FILEPATH "Strip")
63  message(STATUS "Using strip ${CMAKE_STRIP}")
64ENDIF()
65
66IF(NOT CMAKE_DSYMUTIL)
67  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find dsymutil
68   OUTPUT_VARIABLE CMAKE_DSYMUTIL_val
69   ERROR_QUIET
70   OUTPUT_STRIP_TRAILING_WHITESPACE)
71  SET(CMAKE_DSYMUTIL ${CMAKE_DSYMUTIL_val} CACHE FILEPATH "Dsymutil")
72  message(STATUS "Using dsymutil ${CMAKE_DSYMUTIL}")
73ENDIF()
74
75IF(NOT CMAKE_LIBTOOL)
76  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
77   OUTPUT_VARIABLE CMAKE_LIBTOOL_val
78   ERROR_QUIET
79   OUTPUT_STRIP_TRAILING_WHITESPACE)
80  SET(CMAKE_LIBTOOL ${CMAKE_LIBTOOL_val} CACHE FILEPATH "Libtool")
81  message(STATUS "Using libtool ${CMAKE_LIBTOOL}")
82ENDIF()
83
84IF(NOT CMAKE_CODESIGN)
85  execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find codesign
86   OUTPUT_VARIABLE CMAKE_CODESIGN_val
87   ERROR_QUIET
88   OUTPUT_STRIP_TRAILING_WHITESPACE)
89  SET(CMAKE_CODESIGN ${CMAKE_CODESIGN_val} CACHE FILEPATH "Codesign")
90  message(STATUS "Using codesign ${CMAKE_CODESIGN}")
91ENDIF()
92
93IF(NOT CMAKE_CODESIGN_ALLOCATE)
94  execute_process(
95    COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find codesign_allocate
96    OUTPUT_VARIABLE CMAKE_CODESIGN_ALLOCATE_val
97    ERROR_QUIET
98    OUTPUT_STRIP_TRAILING_WHITESPACE)
99  SET(CMAKE_CODESIGN_ALLOCATE ${CMAKE_CODESIGN_ALLOCATE_val} CACHE
100      FILEPATH "Codesign_Allocate")
101  message(STATUS "Using codesign_allocate ${CMAKE_CODESIGN_ALLOCATE}")
102ENDIF()
103