forked from plenluno/ios-cmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HOWTO.txt
143 lines (40 loc) · 3.11 KB
/
HOWTO.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#summary Guide to the ios-cmake project
== Introduction ==
This project provides a simple iOS toolchain file that may be used with CMake to build libraries.
== Contents ==
* [#Toolchain_file]
* [#Sample_library]
* [#Sample_application]
==Toolchain_file==
The toolchain is located in at toolchain/iOS.cmake location. Using the toolchain is quite straightforward. It only requires you to call CMake with:
{{{
cmake -DCMAKE_TOOLCHAIN_FILE=path/to/iOS.cmake -GXcode
}}}
*NOTE:* Since this toolchain by default builds both arm6 and arm7 fat libraries and applications, you need to use the Xcode generator. Makefiles currently do not work.
The iOS.cmake file only has a few different options, all of which are documented in the file itself.
===IOS_PLATFORM===
*Values:* OS (default) or SIMULATOR
This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
* OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
* SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
===CMAKE_IOS_DEVELOPER_ROOT===
*Values:* automatic(default) or /path/to/platform/ eveloper folder
By default this location is automatically chosen based on the IOS_PLATFORM value above. If set manually, it will override the default location and force the user of a particular Developer Platform
===CMAKE_IOS_SDK_ROOT===
*Values:* automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
By default this location is automatically chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. If set manually, this will force the use of a specific SDK version
==Sample_library==
The iOS.cmake toolchain is great for building libraries.
A sample library is located in the samples/hello-lib location. It creates a small static sample library. You can build the library in the standard CMake way using a build subdirectory:
{{{
1. mkdir build.ios
2. cd build.ios
3. cmake -DCMAKE_TOOLCHAIN_FILE=../../../toolchains/iOS.cmake -GXcode ..
4a. Open XCode and build the install target or
4b. Simply type: xcodebuild -target install -configuration Debug
}}}
This will place the library and header file into the samples/hello-app folder.
==Sample_application==
The sample application is located in samples/hello-app. This application uses the library and headers from the hello-lib project which are automatically installed if you built the install target.
Simply open the included Xcode project and build the application for whichever platform you created the build-lib target for (OS or SIMULATOR). Note that you will need to sign the application to deploy it to a device.
*NOTE:* Building an iOS executable application strictly using cmake is not a great idea. There are a large number of options that need to be setup within XCode before a project can simply be deployed onto a device. The whole signing process is a good example. For this reason, we do not attempt to build the hello-app sample using cmake.