forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
516 lines (488 loc) · 10.5 KB
/
CMakeLists.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(jni_dir ${CMAKE_SOURCE_DIR}/src/main/jni)
#
# third-party-ndk
#
set(third_party_ndk_dir ${CMAKE_SOURCE_DIR}/third-party-ndk)
# boost(header-only) https://cmake.org/cmake/help/v3.6/manual/cmake-buildsystem.7.html#interface-libraries
set(boost_dir ${third_party_ndk_dir}/boost)
add_library(boost
INTERFACE)
target_include_directories(
boost
INTERFACE
${boost_dir}/boost_1_66_0
)
# glog libglog.so
set(glog_dir ${third_party_ndk_dir}/glog)
add_library(
glog
SHARED
${glog_dir}/glog-0.3.5/src/demangle.cc
${glog_dir}/glog-0.3.5/src/logging.cc
${glog_dir}/glog-0.3.5/src/raw_logging.cc
${glog_dir}/glog-0.3.5/src/signalhandler.cc
${glog_dir}/glog-0.3.5/src/symbolize.cc
${glog_dir}/glog-0.3.5/src/utilities.cc
${glog_dir}/glog-0.3.5/src/vlog_is_on.cc
)
target_include_directories(
glog
PRIVATE
${glog_dir}
PUBLIC
${glog_dir}/..
${glog_dir}/glog-0.3.5/src
)
target_compile_options(
glog
PRIVATE
-Wall
-Wwrite-strings
-Woverloaded-virtual
-Wno-sign-compare
-g
-O2
)
# XXX _START_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_ 已在 config.h 中定义
target_compile_definitions(
glog
PRIVATE
NDEBUG
)
# double-conversion
set(double-conversion_dir ${third_party_ndk_dir}/double-conversion)
add_library(
double-conversion
STATIC
${double-conversion_dir}/double-conversion/bignum.cc
${double-conversion_dir}/double-conversion/bignum-dtoa.cc
${double-conversion_dir}/double-conversion/cached-powers.cc
${double-conversion_dir}/double-conversion/diy-fp.cc
${double-conversion_dir}/double-conversion/double-conversion.cc
${double-conversion_dir}/double-conversion/fast-dtoa.cc
${double-conversion_dir}/double-conversion/fixed-dtoa.cc
${double-conversion_dir}/double-conversion/strtod.cc
)
target_include_directories(
double-conversion
PUBLIC ${double-conversion_dir}
)
target_compile_options(
double-conversion
PUBLIC
-std=c++14 -Wno-unused-variable -Wno-unused-local-typedefs
)
# folly_json libfolly_json.so
set(folly_json_dir ${third_party_ndk_dir}/folly)
add_library(
folly_json
SHARED
${folly_json_dir}/folly/Conv.cpp
${folly_json_dir}/folly/Demangle.cpp
${folly_json_dir}/folly/Expected.cpp
${folly_json_dir}/folly/Format.cpp
${folly_json_dir}/folly/FormatArg.cpp
${folly_json_dir}/folly/ScopeGuard.cpp
${folly_json_dir}/folly/String.cpp
${folly_json_dir}/folly/Unicode.cpp
${folly_json_dir}/folly/dynamic.cpp
${folly_json_dir}/folly/json.cpp
${folly_json_dir}/folly/Optional.cpp
# ${folly_json_dir}/folly/json_pointer.cpp # 最新master 需要
${folly_json_dir}/folly/lang/Assume.cpp
${folly_json_dir}/folly/lang/ColdClass.cpp
${folly_json_dir}/folly/memory/detail/MallocImpl.cpp
)
target_include_directories(
folly_json
PUBLIC ${folly_json_dir}
)
target_compile_options(
folly_json
PRIVATE
-fexceptions
-frtti
-std=c++14
-Wextra
-g
-finput-charset=UTF-8
-fsigned-char
-Werror
-Wall
-Wno-deprecated
-Wdeprecated-declarations
-Wno-error=deprecated-declarations
-Wno-sign-compare
-Wno-unused
-Wunused-label
-Wunused-result
-Wnon-virtual-dtor
)
target_compile_definitions(
folly_json
PRIVATE
_REENTRANT
_GNU_SOURCE
"FOLLY_XLOG_STRIP_PREFIXES=\"${FOLLY_DIR_PREFIXES}\""
)
target_link_libraries(
folly_json
glog
double-conversion
boost
)
# jsc libjsc.so
set(jsc_dir ${third_party_ndk_dir}/jsc)
add_library(
jsc
SHARED
IMPORTED
)
set_target_properties(
jsc
PROPERTIES IMPORTED_LOCATION
${jsc_dir}/jni/${ANDROID_ABI}/libjsc.so
)
# target_include_directories(jsc PUBLIC ${jsc_dir})
#
# jni common
#
# fb libfb.so
set(fb_dir ${jni_dir}/first-party/fb)
add_library(
fb
SHARED
${fb_dir}/assert.cpp
${fb_dir}/jni/ByteBuffer.cpp
${fb_dir}/jni/Countable.cpp
${fb_dir}/jni/Environment.cpp
${fb_dir}/jni/Exceptions.cpp
${fb_dir}/jni/fbjni.cpp
${fb_dir}/jni/Hybrid.cpp
${fb_dir}/jni/jni_helpers.cpp
${fb_dir}/jni/LocalString.cpp
${fb_dir}/jni/OnLoad.cpp
${fb_dir}/jni/References.cpp
${fb_dir}/jni/WeakReference.cpp
${fb_dir}/log.cpp
${fb_dir}/lyra/lyra.cpp
${fb_dir}/onload.cpp
)
target_include_directories(
fb
PUBLIC ${fb_dir}/include
)
# TODO TOOLCHAIN_PERMISSIVE
target_compile_options(
fb
PRIVATE
-fexceptions -frtti -Wall -Werror -Wno-unused-parameter
PUBLIC
-std=c++14
)
target_compile_definitions(
fb
PRIVATE
LOG_TAG=\"libfb\"
DISABLE_CPUCAP
DISABLE_XPLAT
HAVE_POSIX_CLOCKS
)
target_link_libraries(
fb
PRIVATE
dl
android
PUBLIC
log
)
#
# ReactCommon
#
set(react_common_dir ${CMAKE_SOURCE_DIR}/../ReactCommon)
# jschelpers
set(jschelpers_dir ${react_common_dir}/jschelpers)
add_library(
jschelpers
STATIC
${jschelpers_dir}/JSCHelpers.cpp
${jschelpers_dir}/Unicode.cpp
${jschelpers_dir}/Value.cpp
)
target_include_directories(
jschelpers
PUBLIC
${jsc_dir}
${jschelpers_dir}/..
)
target_compile_options(
jschelpers
PRIVATE
-Wall -Werror -fexceptions -frtti
PUBLIC
-std=c++14
)
target_compile_definitions(
jschelpers
PRIVATE
LOG_TAG=\"ReactNative\"
)
target_link_libraries(
jschelpers
folly_json
jsc
glog
# privatedata # xxx
)
# cxxreact(reactnative)
set(cxxreact_dir ${react_common_dir}/cxxreact)
add_library(
reactnative
STATIC
${cxxreact_dir}/CxxNativeModule.cpp
${cxxreact_dir}/Instance.cpp
${cxxreact_dir}/JSBigString.cpp
${cxxreact_dir}/JSBundleType.cpp
${cxxreact_dir}/JSCExecutor.cpp
${cxxreact_dir}/JSCLegacyTracing.cpp
${cxxreact_dir}/JSCMemory.cpp
${cxxreact_dir}/JSCNativeModules.cpp
${cxxreact_dir}/JSCPerfStats.cpp
${cxxreact_dir}/JSCSamplingProfiler.cpp
${cxxreact_dir}/JSCTracing.cpp
${cxxreact_dir}/JSCUtils.cpp
${cxxreact_dir}/JSIndexedRAMBundle.cpp
${cxxreact_dir}/MethodCall.cpp
${cxxreact_dir}/ModuleRegistry.cpp
${cxxreact_dir}/NativeToJsBridge.cpp
${cxxreact_dir}/Platform.cpp
${cxxreact_dir}/RAMBundleRegistry.cpp
)
target_include_directories(
reactnative
PRIVATE
${jsc_dir}
PUBLIC
${cxxreact_dir}/..
)
target_compile_options(
reactnative
PRIVATE
-Wall -Werror -fexceptions -frtti
-Wno-unused-lambda-capture
-Wno-non-virtual-dtor
PUBLIC
-std=c++14
)
target_compile_definitions(
reactnative
PRIVATE
LOG_TAG=\"ReactNative\"
)
target_link_libraries(
reactnative
jsc
jschelpers
fb
folly_json
glog
jsinspector
# privatedata #xxx
)
# yogacore
set(yogacore_dir ${react_common_dir}/yoga)
file(GLOB_RECURSE yogacore_srcs ${yogacore_dir}/yoga/*.cpp)
add_library(
yogacore
STATIC
${yogacore_srcs}
)
target_include_directories(
yogacore
PUBLIC ${yogacore_dir}
)
target_compile_options(
yogacore
PRIVATE
-Wall -Werror -fexceptions -frtti -std=c++1y -O3
)
# privatedata libprivatedata.so
set(privatedata_dir ${react_common_dir}/privatedata)
add_library(
privatedata
SHARED
${privatedata_dir}/PrivateDataBase.cpp
)
target_include_directories(
privatedata
PUBLIC ${privatedata_dir}/..
)
target_compile_options(
privatedata
PRIVATE
-Wall -Werror -fexceptions -frtti
PUBLIC
-std=c++14
)
target_compile_definitions(
privatedata
PRIVATE
LOG_TAG=\"ReactNative\"
)
# jsinspector .so?
set(jsinspector_dir ${react_common_dir}/jsinspector)
add_library(
jsinspector
SHARED # XXX
${jsinspector_dir}/InspectorInterfaces.cpp
)
target_include_directories(
jsinspector
PUBLIC ${jsinspector_dir}/..
)
target_compile_options(
jsinspector
PRIVATE
-Wall -Werror -fexceptions -frtti
PUBLIC
-std=c++14
)
#
# jni
#
# yoga(libyoga.so)
set(yoga_dir ${jni_dir}/first-party/yogajni)
add_library(
yoga
SHARED
${yoga_dir}/jni/YGJNI.cpp
)
target_include_directories(
yoga
PRIVATE ${yoga_dir}/jni
)
target_compile_options(
yoga
PRIVATE
-Wall -Werror -fvisibility=hidden -fexceptions -frtti -O3
PUBLIC
-std=c++14
)
target_link_libraries(
yoga
android
log
yogacore
fb
)
# glog_init libglog_init.so
set(glog_init_dir ${jni_dir}/first-party/fbgloginit)
add_library(
glog_init
SHARED
${glog_init_dir}/glog_init.cpp
)
target_include_directories(
glog_init
PUBLIC
${glog_init_dir}
)
target_compile_options(
glog_init
PRIVATE
-fexceptions -fno-omit-frame-pointer -Wall -Werror
PUBLIC
-std=c++14
)
target_link_libraries(
glog_init
log
glog
)
# packagerconnectionjnifb ?
#set(packagerconnectionjnifb_dir ${jni_dir}/packagerconnection)
#add_library(
# packagerconnectionjnifb
# SHARED
# ${packagerconnectionjnifb_dir}/JSPackagerClientResponder.h
# ${packagerconnectionjnifb_dir}/SamplingProfilerJniMethod.cpp
#)
#target_include_directories(
# packagerconnectionjnifb
# PRIVATE ${packagerconnectionjnifb_dir}/../..
#)
#target_compile_options(
# packagerconnectionjnifb
# PRIVATE
# -Wall -Werror -fvisibility=hidden -fexceptions -frtti
#)
## TODO fbjni?
#target_link_libraries(
# packagerconnectionjnifb
# PRIVATE
# android
# folly_json
# fb
# jsc
# glog_init
#)
# libreactnativejni.so
set(reactnativejni_dir ${jni_dir}/react/jni)
add_library(
reactnativejni
SHARED
${reactnativejni_dir}/AndroidJSCFactory.cpp
${reactnativejni_dir}/CatalystInstanceImpl.cpp
${reactnativejni_dir}/CxxModuleWrapper.cpp
${reactnativejni_dir}/JavaModuleWrapper.cpp
${reactnativejni_dir}/JMessageQueueThread.cpp
${reactnativejni_dir}/JSCPerfLogging.cpp
${reactnativejni_dir}/JSLoader.cpp
${reactnativejni_dir}/JSLogging.cpp
${reactnativejni_dir}/JniJSModulesUnbundle.cpp
${reactnativejni_dir}/MethodInvoker.cpp
${reactnativejni_dir}/ModuleRegistryBuilder.cpp
${reactnativejni_dir}/NativeArray.cpp
${reactnativejni_dir}/NativeCommon.cpp
${reactnativejni_dir}/NativeMap.cpp
${reactnativejni_dir}/OnLoad.cpp
${reactnativejni_dir}/ProxyExecutor.cpp
${reactnativejni_dir}/ReactMarker.cpp
${reactnativejni_dir}/ReadableNativeArray.cpp
${reactnativejni_dir}/ReadableNativeMap.cpp
${reactnativejni_dir}/WritableNativeArray.cpp
${reactnativejni_dir}/WritableNativeMap.cpp
)
target_include_directories(
reactnativejni
PRIVATE
${jsc_dir}
PUBLIC
${reactnativejni_dir}/../..
)
target_compile_options(
reactnativejni
PRIVATE
-Wall -Werror -fvisibility=hidden -fexceptions -frtti
-Wno-unused-lambda-capture
PUBLIC
-std=c++14
)
# TODO fbjni?
target_link_libraries(
reactnativejni
PRIVATE
android
folly_json
fb
jsc
glog_init
yoga
privatedata
reactnative
)