-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
723 lines (627 loc) · 33.8 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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
cmake_minimum_required(VERSION 3.10)
project(pluto)
# 添加编译选项
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 把lua头文件添加到全局搜索路径
include_directories(skynet/3rd/lua/)
# Linux
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
message(STATUS "current platform: Linux")
add_compile_definitions(NOUSE_JEMALLOC LUA_USE_LINUX LUA_USE_READLINE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall ")
set(CMAKE_SHARED_LINKER_FLAGS " -fPIC --shared -Wl,-E")
# 添加编译选项
add_compile_options(-g)
#设置输出目录
set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/pluto)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
message(STATUS "The value of CMAKE_BINARY_DIR is: ${CMAKE_BINARY_DIR}")
aux_source_directory(skynet/3rd/lua LUA_LIB_SRC)
list(REMOVE_ITEM LUA_LIB_SRC
"skynet/3rd/lua/lua.c"
"skynet/3rd/lua/luac.c"
"skynet/3rd/lua/onelua.c"
"skynet/3rd/lua/ltests.c")
message(STATUS "The value of LUA_LIB_SRC is: ${LUA_LIB_SRC}")
# 编译 lua 可执行文件
add_executable(lua ${LUA_LIB_SRC} "skynet/3rd/lua/lua.c")
target_include_directories(lua PRIVATE skynet/skynet-src)
target_link_libraries(lua m readline)
# 编译 luac 可执行文件
add_executable(luac ${LUA_LIB_SRC} "skynet/3rd/lua/luac.c")
target_include_directories(luac PRIVATE skynet/skynet-src)
target_link_libraries(luac m readline)
# 编译 skynet 可执行文件
aux_source_directory(skynet/skynet-src SKYNET_SRC)
message(STATUS "The value of SKYNET_SRC is: ${SKYNET_SRC}")
add_executable(skynet ${SKYNET_SRC} ${LUA_LIB_SRC})
target_include_directories(skynet PRIVATE skynet/skynet-src)
target_link_options(skynet PRIVATE "LINKER:-E")
target_link_libraries(skynet m pthread dl rt)
# 重新设置动态库输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/luaclib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/luaclib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# 生成动态库 skynet.so
set(LUA_CLIB_SKYNET_SRC
skynet/lualib-src/lua-skynet.c
skynet/lualib-src/lua-seri.c
skynet/lualib-src/lua-socket.c
skynet/lualib-src/lua-mongo.c
skynet/lualib-src/lua-netpack.c
skynet/lualib-src/lua-memory.c
skynet/lualib-src/lua-multicast.c
skynet/lualib-src/lua-cluster.c
skynet/lualib-src/lua-crypt.c
skynet/lualib-src/lsha1.c
skynet/lualib-src/lua-sharedata.c
skynet/lualib-src/lua-stm.c
skynet/lualib-src/lua-debugchannel.c
skynet/lualib-src/lua-datasheet.c
skynet/lualib-src/lua-sharetable.c )
add_library(skynetso SHARED ${LUA_CLIB_SKYNET_SRC})
target_include_directories(skynetso PRIVATE skynet/skynet-src skynet/lualib-src)
set_target_properties(skynetso PROPERTIES OUTPUT_NAME skynet)
set_target_properties(skynetso PROPERTIES PREFIX "")
# 生成动态库 bson.so
add_library(bson SHARED skynet/lualib-src/lua-bson.c)
target_include_directories(bson PRIVATE skynet/skynet-src)
# 生成动态库 md5.so
aux_source_directory(skynet/3rd/lua-md5 LUA_MD5_SRC)
add_library(md5 SHARED ${LUA_MD5_SRC})
# 生成动态库 client.so
add_library(client SHARED skynet/lualib-src/lua-clientsocket.c
skynet/lualib-src/lua-crypt.c
skynet/lualib-src/lsha1.c)
target_link_libraries(client pthread)
# 生成动态库 sproto.so
aux_source_directory(skynet/lualib-src/sproto SPROTO_SRC)
add_library(sproto SHARED ${SPROTO_SRC})
# 生成动态库 lpeg.so
aux_source_directory(skynet/3rd/lpeg LPEG_SRC)
add_library(lpeg SHARED ${LPEG_SRC})
# 生成动态库 ltls.so
add_library(ltls SHARED skynet/lualib-src/ltls.c)
target_include_directories(ltls PRIVATE 3rd/openssl/include/)
target_link_directories(ltls PRIVATE 3rd/openssl/lib/linux/)
target_link_libraries(ltls ssl crypto)
# 生成动态库 pb.so
aux_source_directory(pluto/luaclib/lua-protobuf PB_SRC)
add_library(pb SHARED ${PB_SRC})
# 生成动态库 lfs.so
aux_source_directory(pluto/luaclib/luafilesystem LFS_SRC)
add_library(lfs SHARED ${LFS_SRC})
# 生成动态库 fmt.so
aux_source_directory(pluto/luaclib/lua-fmt FMT_SRC)
add_library(fmt SHARED ${FMT_SRC})
# 生成动态库 yyjson.so
aux_source_directory(pluto/luaclib/lua-yyjson YYJSON_SRC)
add_library(yyjson SHARED ${YYJSON_SRC})
# 生成动态库 zset.so
aux_source_directory(pluto/luaclib/lua-zset ZSET_SRC)
add_library(zset SHARED ${ZSET_SRC})
# 生成动态库 aoi.so
aux_source_directory(pluto/luaclib/lua-aoi AOI_SRC)
add_library(aoi SHARED ${AOI_SRC})
# 生成动态库 navmesh.so
aux_source_directory(pluto/luaclib/lua-navmesh NAVMESH_SRC)
aux_source_directory(3rd/recastnavigation/Detour/Source Detour_SRC)
aux_source_directory(3rd/recastnavigation/DetourCrowd/Source DetourCrowd_SRC)
aux_source_directory(3rd/recastnavigation/DetourTileCache/Source DetourTileCache_SRC)
aux_source_directory(3rd/recastnavigation/Recast/Source Recast_SRC)
add_library(navmesh SHARED ${NAVMESH_SRC}
${Detour_SRC} ${DetourCrowd_SRC}
${DetourTileCache_SRC} ${Recast_SRC})
target_include_directories(navmesh PRIVATE
3rd/recastnavigation/Detour/Include/
3rd/recastnavigation/DetourCrowd/Include/
3rd/recastnavigation/DetourTileCache/Include/
3rd/recastnavigation/Recast/Include/)
# 生成动态库 math3d.so
aux_source_directory(pluto/luaclib/math3d MATH3D_SRC)
add_library(math3d SHARED ${MATH3D_SRC})
target_include_directories(math3d PRIVATE 3rd/glm/include/)
target_compile_definitions(math3d PUBLIC -DGLM_ENABLE_EXPERIMENTAL -DGLM_FORCE_QUAT_DATA_XYZW)
# 生成动态库 rp3d.so
aux_source_directory(pluto/luaclib/lua-rp3d RP3D_SRC)
aux_source_directory(3rd/reactphysics3d/src/body/ RP3D_body_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/ RP3D_collision_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/broadphase/ RP3D_collision_broadphase_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/ RP3D_collision_narrowphase_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/GJK/ RP3D_collision_narrowphase_GJK_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/SAT/ RP3D_collision_narrowphase_SAT_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/shapes/ RP3D_collision_shapes_SRC)
aux_source_directory(3rd/reactphysics3d/src/components/ RP3D_components_SRC)
aux_source_directory(3rd/reactphysics3d/src/constraint/ RP3D_constraint_SRC)
aux_source_directory(3rd/reactphysics3d/src/engine/ RP3D_engine_SRC)
aux_source_directory(3rd/reactphysics3d/src/mathematics/ RP3D_mathematics_SRC)
aux_source_directory(3rd/reactphysics3d/src/memory/ RP3D_memory_SRC)
aux_source_directory(3rd/reactphysics3d/src/systems/ RP3D_systems_SRC)
aux_source_directory(3rd/reactphysics3d/src/utils/ RP3D_utils_SRC)
aux_source_directory(3rd/reactphysics3d/src/utils/quickhull/ RP3D_utils_quickhull_SRC)
add_library(rp3d SHARED ${RP3D_SRC} ${RP3D_body_SRC}
${RP3D_collision_SRC} ${RP3D_collision_broadphase_SRC}
${RP3D_collision_narrowphase_SRC} ${RP3D_collision_narrowphase_GJK_SRC}
${RP3D_collision_narrowphase_SAT_SRC} ${RP3D_collision_shapes_SRC}
${RP3D_components_SRC} ${RP3D_constraint_SRC}
${RP3D_engine_SRC} ${RP3D_mathematics_SRC}
${RP3D_memory_SRC} ${RP3D_systems_SRC}
${RP3D_utils_SRC} ${RP3D_utils_quickhull_SRC} )
target_include_directories(rp3d PRIVATE 3rd/reactphysics3d/include/
3rd/reactphysics3d/include/reactphysics3d/body/
3rd/reactphysics3d/include/reactphysics3d/collision/
3rd/reactphysics3d/include/reactphysics3d/collision/broadphase/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/SAT/
3rd/reactphysics3d/include/reactphysics3d/collision/shapes/
3rd/reactphysics3d/include/reactphysics3d/components/
3rd/reactphysics3d/include/reactphysics3d/constraint/
3rd/reactphysics3d/include/reactphysics3d/containers/
3rd/reactphysics3d/include/reactphysics3d/engine/
3rd/reactphysics3d/include/reactphysics3d/mathematics/
3rd/reactphysics3d/include/reactphysics3d/memory/
3rd/reactphysics3d/include/reactphysics3d/systems/
3rd/reactphysics3d/include/reactphysics3d/utils/
3rd/reactphysics3d/include/reactphysics3d/utils/quickhull/ )
# 生成动态库 lsyslog.so
aux_source_directory(pluto/luaclib/luasyslog SYSLOG_SRC)
add_library(lsyslog SHARED ${SYSLOG_SRC})
# 生成动态库 miniz.so
aux_source_directory(pluto/luaclib/lua-miniz Z_SRC)
add_library(miniz SHARED ${Z_SRC})
# 生成动态库 clonefunc.so
aux_source_directory(pluto/luaclib/clonefunc CLONEFUNC_SRC)
add_library(clonefunc SHARED ${CLONEFUNC_SRC} ${LUA_LIB_SRC})
target_include_directories(clonefunc PRIVATE skynet/skynet-src)
set_target_properties(
lpeg sproto client md5 bson ltls
pb lfs fmt yyjson zset aoi navmesh
math3d rp3d lsyslog miniz clonefunc
PROPERTIES
PREFIX ""
SUFFIX .so )
# 重新设置动态库输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/cservice)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/cservice)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# 生成c服务
file(GLOB CSERVICE_FILE_LIST "skynet/service-src/*.c")
message(STATUS "The value of CSERVICE_FILE_LIST is: ${CSERVICE_FILE_LIST}")
foreach(FILE_PATH IN LISTS CSERVICE_FILE_LIST)
message(STATUS "Processing file: ${FILE_PATH}")
string(REGEX REPLACE ".*skynet/service-src/service_" "" LIB_NAME "${FILE_PATH}")
string(REGEX REPLACE ".c$" "" LIB_NAME "${LIB_NAME}")
message(STATUS "The value of LIB_NAME is: ${LIB_NAME}")
add_library(${LIB_NAME} SHARED ${FILE_PATH})
target_include_directories(${LIB_NAME} PRIVATE skynet/skynet-src)
set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
endforeach()
endif ()
# Windows
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
message(STATUS "current platform: Windows")
add_compile_definitions(NOUSE_JEMALLOC LUA_BUILD_AS_DLL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-int-conversion -Wno-implicit-function-declaration -Wno-deprecated-declarations")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
#设置输出目录
set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/pluto)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
message(STATUS "The value of CMAKE_BINARY_DIR is: ${CMAKE_BINARY_DIR}")
# 把lua头文件添加到全局搜索路径
include_directories(3rd/posix 3rd/pthread-win32 skynet/skynet-src)
add_compile_options(/FI ${CMAKE_SOURCE_DIR}/3rd/posix/unistd.h)
aux_source_directory(skynet/3rd/lua LUA_LIB_SRC)
list(REMOVE_ITEM LUA_LIB_SRC
"skynet/3rd/lua/lua.c"
"skynet/3rd/lua/luac.c"
"skynet/3rd/lua/onelua.c"
"skynet/3rd/lua/ltests.c")
message(STATUS "The value of LUA_LIB_SRC is: ${LUA_LIB_SRC}")
# 编译 lua 可执行文件
add_executable(lua ${LUA_LIB_SRC} "skynet/3rd/lua/lua.c")
target_include_directories(lua PRIVATE skynet/skynet-src)
target_link_libraries(lua ws2_32)
# 编译 luac 可执行文件
add_executable(luac ${LUA_LIB_SRC} "skynet/3rd/lua/luac.c")
target_include_directories(luac PRIVATE skynet/skynet-src)
target_link_libraries(luac ws2_32)
aux_source_directory(skynet/skynet-src LIB_SKYNET_SRC)
list(REMOVE_ITEM LIB_SKYNET_SRC skynet/skynet-src/skynet_main.c)
aux_source_directory(3rd/posix POSIX_SRC)
add_subdirectory(3rd/pthread-win32)
add_library(liblua SHARED ${LUA_LIB_SRC})
add_library(libposix SHARED ${POSIX_SRC})
target_compile_definitions(libposix PRIVATE POSIX_LIBRARY)
target_link_libraries(libposix ws2_32)
add_library(libskynet SHARED ${LIB_SKYNET_SRC})
target_link_libraries(libskynet liblua libposix pthreadVC3)
# 编译 skynet 可执行文件
add_executable(skynet skynet/skynet-src/skynet_main.c)
target_link_libraries(skynet ws2_32 liblua libposix libskynet pthreadVC3)
# 重新设置动态库输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/luaclib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/luaclib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# 生成动态库 skynet.so
set(LUA_CLIB_SKYNET_SRC
skynet/lualib-src/lua-skynet.c
skynet/lualib-src/lua-seri.c
skynet/lualib-src/lua-socket.c
skynet/lualib-src/lua-mongo.c
skynet/lualib-src/lua-netpack.c
skynet/lualib-src/lua-memory.c
skynet/lualib-src/lua-multicast.c
skynet/lualib-src/lua-cluster.c
skynet/lualib-src/lua-crypt.c
skynet/lualib-src/lsha1.c
skynet/lualib-src/lua-sharedata.c
skynet/lualib-src/lua-stm.c
skynet/lualib-src/lua-debugchannel.c
skynet/lualib-src/lua-datasheet.c
skynet/lualib-src/lua-sharetable.c )
message(STATUS "The value of LIB_SKYNET_SRC is: ${LIB_SKYNET_SRC}")
add_library(skynetso SHARED ${LUA_CLIB_SKYNET_SRC})
target_compile_definitions(skynetso PUBLIC LUA_LIB)
set_target_properties(skynetso PROPERTIES OUTPUT_NAME skynet)
target_link_libraries(skynetso ws2_32 libskynet)
# 生成动态库 bson.so
add_library(bson SHARED skynet/lualib-src/lua-bson.c)
target_link_libraries(bson ws2_32 liblua)
# 生成动态库 md5.so
aux_source_directory(skynet/3rd/lua-md5 LUA_MD5_SRC)
add_library(md5 SHARED ${LUA_MD5_SRC})
target_link_libraries(md5 liblua)
# 生成动态库 client.so
add_library(client SHARED skynet/lualib-src/lua-clientsocket.c
skynet/lualib-src/lua-crypt.c
skynet/lualib-src/lsha1.c)
target_link_libraries(client ws2_32 liblua libposix pthreadVC3)
# 生成动态库 sproto.so
aux_source_directory(skynet/lualib-src/sproto SPROTO_SRC)
add_library(sproto SHARED ${SPROTO_SRC})
target_link_libraries(sproto liblua)
# 生成动态库 lpeg.so
aux_source_directory(skynet/3rd/lpeg LPEG_SRC)
add_library(lpeg SHARED ${LPEG_SRC})
target_link_libraries(lpeg liblua)
# 生成动态库 ltls.so
add_library(ltls SHARED skynet/lualib-src/ltls.c)
target_include_directories(ltls PRIVATE 3rd/openssl/include/)
target_link_directories(ltls PRIVATE 3rd/openssl/lib/windows/)
target_link_libraries(ltls ws2_32 mswsock liblua libposix pthreadVC3 libssl libcrypto Crypt32)
# 生成动态库 pb.so
aux_source_directory(pluto/luaclib/lua-protobuf PB_SRC)
add_library(pb SHARED ${PB_SRC})
target_link_libraries(pb liblua)
# 生成动态库 lfs.so
aux_source_directory(pluto/luaclib/luafilesystem LFS_SRC)
add_library(lfs SHARED ${LFS_SRC})
target_link_libraries(lfs liblua)
# 生成动态库 fmt.so
aux_source_directory(pluto/luaclib/lua-fmt FMT_SRC)
add_library(fmt SHARED ${FMT_SRC})
target_link_libraries(fmt liblua)
# 生成动态库 yyjson.so
aux_source_directory(pluto/luaclib/lua-yyjson YYJSON_SRC)
add_library(yyjson SHARED ${YYJSON_SRC})
target_link_libraries(yyjson liblua)
# 生成动态库 zset.so
aux_source_directory(pluto/luaclib/lua-zset ZSET_SRC)
add_library(zset SHARED ${ZSET_SRC})
target_link_libraries(zset liblua)
# 生成动态库 aoi.so
aux_source_directory(pluto/luaclib/lua-aoi AOI_SRC)
add_library(aoi SHARED ${AOI_SRC})
target_link_libraries(aoi liblua)
# 生成动态库 navmesh.so
aux_source_directory(pluto/luaclib/lua-navmesh NAVMESH_SRC)
aux_source_directory(3rd/recastnavigation/Detour/Source Detour_SRC)
aux_source_directory(3rd/recastnavigation/DetourCrowd/Source DetourCrowd_SRC)
aux_source_directory(3rd/recastnavigation/DetourTileCache/Source DetourTileCache_SRC)
aux_source_directory(3rd/recastnavigation/Recast/Source Recast_SRC)
add_library(navmesh SHARED ${NAVMESH_SRC}
${Detour_SRC} ${DetourCrowd_SRC}
${DetourTileCache_SRC} ${Recast_SRC})
target_include_directories(navmesh PRIVATE
3rd/recastnavigation/Detour/Include/
3rd/recastnavigation/DetourCrowd/Include/
3rd/recastnavigation/DetourTileCache/Include/
3rd/recastnavigation/Recast/Include/)
target_link_libraries(navmesh liblua)
# 生成动态库 math3d.so
aux_source_directory(pluto/luaclib/math3d MATH3D_SRC)
add_library(math3d SHARED ${MATH3D_SRC})
target_include_directories(math3d PRIVATE 3rd/glm/include/)
target_compile_definitions(math3d PUBLIC -DGLM_ENABLE_EXPERIMENTAL -DGLM_FORCE_QUAT_DATA_XYZW)
target_link_libraries(math3d liblua)
# 生成动态库 rp3d.so
aux_source_directory(pluto/luaclib/lua-rp3d RP3D_SRC)
aux_source_directory(3rd/reactphysics3d/src/body/ RP3D_body_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/ RP3D_collision_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/broadphase/ RP3D_collision_broadphase_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/ RP3D_collision_narrowphase_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/GJK/ RP3D_collision_narrowphase_GJK_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/SAT/ RP3D_collision_narrowphase_SAT_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/shapes/ RP3D_collision_shapes_SRC)
aux_source_directory(3rd/reactphysics3d/src/components/ RP3D_components_SRC)
aux_source_directory(3rd/reactphysics3d/src/constraint/ RP3D_constraint_SRC)
aux_source_directory(3rd/reactphysics3d/src/engine/ RP3D_engine_SRC)
aux_source_directory(3rd/reactphysics3d/src/mathematics/ RP3D_mathematics_SRC)
aux_source_directory(3rd/reactphysics3d/src/memory/ RP3D_memory_SRC)
aux_source_directory(3rd/reactphysics3d/src/systems/ RP3D_systems_SRC)
aux_source_directory(3rd/reactphysics3d/src/utils/ RP3D_utils_SRC)
aux_source_directory(3rd/reactphysics3d/src/utils/quickhull/ RP3D_utils_quickhull_SRC)
add_library(rp3d SHARED ${RP3D_SRC} ${RP3D_body_SRC}
${RP3D_collision_SRC} ${RP3D_collision_broadphase_SRC}
${RP3D_collision_narrowphase_SRC} ${RP3D_collision_narrowphase_GJK_SRC}
${RP3D_collision_narrowphase_SAT_SRC} ${RP3D_collision_shapes_SRC}
${RP3D_components_SRC} ${RP3D_constraint_SRC}
${RP3D_engine_SRC} ${RP3D_mathematics_SRC}
${RP3D_memory_SRC} ${RP3D_systems_SRC}
${RP3D_utils_SRC} ${RP3D_utils_quickhull_SRC} )
target_include_directories(rp3d PRIVATE 3rd/reactphysics3d/include/
3rd/reactphysics3d/include/reactphysics3d/body/
3rd/reactphysics3d/include/reactphysics3d/collision/
3rd/reactphysics3d/include/reactphysics3d/collision/broadphase/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/SAT/
3rd/reactphysics3d/include/reactphysics3d/collision/shapes/
3rd/reactphysics3d/include/reactphysics3d/components/
3rd/reactphysics3d/include/reactphysics3d/constraint/
3rd/reactphysics3d/include/reactphysics3d/containers/
3rd/reactphysics3d/include/reactphysics3d/engine/
3rd/reactphysics3d/include/reactphysics3d/mathematics/
3rd/reactphysics3d/include/reactphysics3d/memory/
3rd/reactphysics3d/include/reactphysics3d/systems/
3rd/reactphysics3d/include/reactphysics3d/utils/
3rd/reactphysics3d/include/reactphysics3d/utils/quickhull/ )
target_link_libraries(rp3d liblua)
# 生成动态库 miniz.so
aux_source_directory(pluto/luaclib/lua-miniz Z_SRC)
add_library(miniz SHARED ${Z_SRC})
target_link_libraries(miniz liblua)
# 生成动态库 clonefunc.so
aux_source_directory(pluto/luaclib/clonefunc CLONEFUNC_SRC)
add_library(clonefunc SHARED ${CLONEFUNC_SRC} ${LUA_LIB_SRC})
target_include_directories(clonefunc PRIVATE skynet/skynet-src)
# 设置动态库属性
set_target_properties(
lpeg sproto client md5 bson skynetso ltls
pb lfs fmt yyjson zset aoi navmesh
math3d rp3d miniz clonefunc
PROPERTIES
PREFIX ""
SUFFIX .so )
# 重新设置动态库输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/cservice)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/cservice)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# 生成c服务
file(GLOB CSERVICE_FILE_LIST "skynet/service-src/*.c")
message(STATUS "The value of CSERVICE_FILE_LIST is: ${CSERVICE_FILE_LIST}")
foreach(FILE_PATH IN LISTS CSERVICE_FILE_LIST)
message(STATUS "Processing file: ${FILE_PATH}")
string(REGEX REPLACE ".*skynet/service-src/service_" "" LIB_NAME "${FILE_PATH}")
string(REGEX REPLACE ".c$" "" LIB_NAME "${LIB_NAME}")
message(STATUS "The value of LIB_NAME is: ${LIB_NAME}")
add_library(${LIB_NAME} SHARED ${FILE_PATH})
target_link_libraries(${LIB_NAME} ws2_32 libskynet)
set_target_properties(${LIB_NAME} PROPERTIES PREFIX "" SUFFIX .so ENABLE_EXPORTS ON)
endforeach()
endif ()
# MacOS
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
message(STATUS "current platform: Mac OS X")
add_compile_definitions(NOUSE_JEMALLOC LUA_USE_MACOSX LUA_USE_READLINE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall ")
set(CMAKE_SHARED_LINKER_FLAGS " -fPIC -dynamiclib -Wl,-undefined,dynamic_lookup")
# 添加编译选项
add_compile_options(-g)
#设置输出目录
set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/pluto)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
message(STATUS "The value of CMAKE_BINARY_DIR is: ${CMAKE_BINARY_DIR}")
aux_source_directory(skynet/3rd/lua LUA_LIB_SRC)
list(REMOVE_ITEM LUA_LIB_SRC
"skynet/3rd/lua/lua.c"
"skynet/3rd/lua/luac.c"
"skynet/3rd/lua/onelua.c"
"skynet/3rd/lua/ltests.c")
message(STATUS "The value of LUA_LIB_SRC is: ${LUA_LIB_SRC}")
# 编译 lua 可执行文件
add_executable(lua ${LUA_LIB_SRC} "skynet/3rd/lua/lua.c")
target_include_directories(lua PRIVATE skynet/skynet-src)
target_link_libraries(lua m readline)
# 编译 luac 可执行文件
add_executable(luac ${LUA_LIB_SRC} "skynet/3rd/lua/luac.c")
target_include_directories(luac PRIVATE skynet/skynet-src)
target_link_libraries(luac m readline)
# 编译 skynet 可执行文件
aux_source_directory(skynet/skynet-src SKYNET_SRC)
message(STATUS "The value of SKYNET_SRC is: ${SKYNET_SRC}")
add_executable(skynet ${SKYNET_SRC} ${LUA_LIB_SRC})
target_include_directories(skynet PRIVATE skynet/skynet-src)
target_link_options(skynet PRIVATE)
target_link_libraries(skynet m pthread dl)
# 重新设置动态库输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/luaclib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/luaclib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# 生成动态库 skynet.so
set(LUA_CLIB_SKYNET_SRC
skynet/lualib-src/lua-skynet.c
skynet/lualib-src/lua-seri.c
skynet/lualib-src/lua-socket.c
skynet/lualib-src/lua-mongo.c
skynet/lualib-src/lua-netpack.c
skynet/lualib-src/lua-memory.c
skynet/lualib-src/lua-multicast.c
skynet/lualib-src/lua-cluster.c
skynet/lualib-src/lua-crypt.c
skynet/lualib-src/lsha1.c
skynet/lualib-src/lua-sharedata.c
skynet/lualib-src/lua-stm.c
skynet/lualib-src/lua-debugchannel.c
skynet/lualib-src/lua-datasheet.c
skynet/lualib-src/lua-sharetable.c )
add_library(skynetso SHARED ${LUA_CLIB_SKYNET_SRC})
target_include_directories(skynetso PRIVATE skynet/skynet-src skynet/lualib-src)
set_target_properties(skynetso PROPERTIES OUTPUT_NAME skynet)
set_target_properties(skynetso PROPERTIES PREFIX "" SUFFIX .so)
# 生成动态库 bson.so
add_library(bson SHARED skynet/lualib-src/lua-bson.c)
target_include_directories(bson PRIVATE skynet/skynet-src)
# 生成动态库 md5.so
aux_source_directory(skynet/3rd/lua-md5 LUA_MD5_SRC)
add_library(md5 SHARED ${LUA_MD5_SRC})
# 生成动态库 client.so
add_library(client SHARED skynet/lualib-src/lua-clientsocket.c
skynet/lualib-src/lua-crypt.c
skynet/lualib-src/lsha1.c)
target_link_libraries(client pthread)
# 生成动态库 sproto.so
aux_source_directory(skynet/lualib-src/sproto SPROTO_SRC)
add_library(sproto SHARED ${SPROTO_SRC})
# 生成动态库 lpeg.so
aux_source_directory(skynet/3rd/lpeg LPEG_SRC)
add_library(lpeg SHARED ${LPEG_SRC})
# 生成动态库 ltls.so
add_library(ltls SHARED skynet/lualib-src/ltls.c)
target_include_directories(ltls PRIVATE 3rd/openssl/include/)
target_link_directories(ltls PRIVATE 3rd/openssl/lib/mac/)
target_link_libraries(ltls ssl crypto)
# 生成动态库 pb.so
aux_source_directory(pluto/luaclib/lua-protobuf PB_SRC)
add_library(pb SHARED ${PB_SRC})
# 生成动态库 lfs.so
aux_source_directory(pluto/luaclib/luafilesystem LFS_SRC)
add_library(lfs SHARED ${LFS_SRC})
# 生成动态库 fmt.so
aux_source_directory(pluto/luaclib/lua-fmt FMT_SRC)
add_library(fmt SHARED ${FMT_SRC})
# 生成动态库 yyjson.so
aux_source_directory(pluto/luaclib/lua-yyjson YYJSON_SRC)
add_library(yyjson SHARED ${YYJSON_SRC})
# 生成动态库 zset.so
aux_source_directory(pluto/luaclib/lua-zset ZSET_SRC)
add_library(zset SHARED ${ZSET_SRC})
# 生成动态库 aoi.so
aux_source_directory(pluto/luaclib/lua-aoi AOI_SRC)
add_library(aoi SHARED ${AOI_SRC})
# 生成动态库 navmesh.so
aux_source_directory(pluto/luaclib/lua-navmesh NAVMESH_SRC)
aux_source_directory(3rd/recastnavigation/Detour/Source Detour_SRC)
aux_source_directory(3rd/recastnavigation/DetourCrowd/Source DetourCrowd_SRC)
aux_source_directory(3rd/recastnavigation/DetourTileCache/Source DetourTileCache_SRC)
aux_source_directory(3rd/recastnavigation/Recast/Source Recast_SRC)
add_library(navmesh SHARED ${NAVMESH_SRC}
${Detour_SRC} ${DetourCrowd_SRC}
${DetourTileCache_SRC} ${Recast_SRC} )
target_include_directories(navmesh PRIVATE
3rd/recastnavigation/Detour/Include/
3rd/recastnavigation/DetourCrowd/Include/
3rd/recastnavigation/DetourTileCache/Include/
3rd/recastnavigation/Recast/Include/)
# 生成动态库 math3d.so
aux_source_directory(pluto/luaclib/math3d MATH3D_SRC)
add_library(math3d SHARED ${MATH3D_SRC})
target_include_directories(math3d PRIVATE 3rd/glm/include/)
target_compile_definitions(math3d PRIVATE -DGLM_ENABLE_EXPERIMENTAL -DGLM_FORCE_QUAT_DATA_XYZW)
# 生成动态库 rp3d.so
aux_source_directory(pluto/luaclib/lua-rp3d RP3D_SRC)
aux_source_directory(3rd/reactphysics3d/src/body/ RP3D_body_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/ RP3D_collision_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/broadphase/ RP3D_collision_broadphase_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/ RP3D_collision_narrowphase_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/GJK/ RP3D_collision_narrowphase_GJK_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/narrowphase/SAT/ RP3D_collision_narrowphase_SAT_SRC)
aux_source_directory(3rd/reactphysics3d/src/collision/shapes/ RP3D_collision_shapes_SRC)
aux_source_directory(3rd/reactphysics3d/src/components/ RP3D_components_SRC)
aux_source_directory(3rd/reactphysics3d/src/constraint/ RP3D_constraint_SRC)
aux_source_directory(3rd/reactphysics3d/src/engine/ RP3D_engine_SRC)
aux_source_directory(3rd/reactphysics3d/src/mathematics/ RP3D_mathematics_SRC)
aux_source_directory(3rd/reactphysics3d/src/memory/ RP3D_memory_SRC)
aux_source_directory(3rd/reactphysics3d/src/systems/ RP3D_systems_SRC)
aux_source_directory(3rd/reactphysics3d/src/utils/ RP3D_utils_SRC)
aux_source_directory(3rd/reactphysics3d/src/utils/quickhull/ RP3D_utils_quickhull_SRC)
add_library(rp3d SHARED ${RP3D_SRC} ${RP3D_body_SRC}
${RP3D_collision_SRC} ${RP3D_collision_broadphase_SRC}
${RP3D_collision_narrowphase_SRC} ${RP3D_collision_narrowphase_GJK_SRC}
${RP3D_collision_narrowphase_SAT_SRC} ${RP3D_collision_shapes_SRC}
${RP3D_components_SRC} ${RP3D_constraint_SRC}
${RP3D_engine_SRC} ${RP3D_mathematics_SRC}
${RP3D_memory_SRC} ${RP3D_systems_SRC}
${RP3D_utils_SRC} ${RP3D_utils_quickhull_SRC} )
target_include_directories(rp3d PRIVATE 3rd/reactphysics3d/include/
3rd/reactphysics3d/include/reactphysics3d/body/
3rd/reactphysics3d/include/reactphysics3d/collision/
3rd/reactphysics3d/include/reactphysics3d/collision/broadphase/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/GJK/
3rd/reactphysics3d/include/reactphysics3d/collision/narrowphase/SAT/
3rd/reactphysics3d/include/reactphysics3d/collision/shapes/
3rd/reactphysics3d/include/reactphysics3d/components/
3rd/reactphysics3d/include/reactphysics3d/constraint/
3rd/reactphysics3d/include/reactphysics3d/containers/
3rd/reactphysics3d/include/reactphysics3d/engine/
3rd/reactphysics3d/include/reactphysics3d/mathematics/
3rd/reactphysics3d/include/reactphysics3d/memory/
3rd/reactphysics3d/include/reactphysics3d/systems/
3rd/reactphysics3d/include/reactphysics3d/utils/
3rd/reactphysics3d/include/reactphysics3d/utils/quickhull/ )
# 生成动态库 lsyslog.so
aux_source_directory(pluto/luaclib/luasyslog SYSLOG_SRC)
add_library(lsyslog SHARED ${SYSLOG_SRC})
# 生成动态库 miniz.so
aux_source_directory(pluto/luaclib/lua-miniz Z_SRC)
add_library(miniz SHARED ${Z_SRC})
# 生成动态库 clonefunc.so
aux_source_directory(pluto/luaclib/clonefunc CLONEFUNC_SRC)
add_library(clonefunc SHARED ${CLONEFUNC_SRC} ${LUA_LIB_SRC})
target_include_directories(clonefunc PRIVATE skynet/skynet-src)
set_target_properties(
lpeg sproto client md5 bson ltls
pb lfs fmt yyjson zset aoi navmesh
math3d rp3d lsyslog miniz clonefunc
PROPERTIES
PREFIX ""
SUFFIX .so )
# 重新设置动态库输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/cservice)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/cservice)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# 生成c服务
file(GLOB CSERVICE_FILE_LIST "skynet/service-src/*.c")
message(STATUS "The value of CSERVICE_FILE_LIST is: ${CSERVICE_FILE_LIST}")
foreach(FILE_PATH IN LISTS CSERVICE_FILE_LIST)
message(STATUS "Processing file: ${FILE_PATH}")
string(REGEX REPLACE ".*skynet/service-src/service_" "" LIB_NAME "${FILE_PATH}")
string(REGEX REPLACE ".c$" "" LIB_NAME "${LIB_NAME}")
message(STATUS "The value of LIB_NAME is: ${LIB_NAME}")
add_library(${LIB_NAME} SHARED ${FILE_PATH})
target_include_directories(${LIB_NAME} PRIVATE skynet/skynet-src)
set_target_properties(${LIB_NAME} PROPERTIES PREFIX "" SUFFIX .so)
endforeach()
endif ()
# 拷贝其他文件
# CMAKE_SOURCE_DIR
message(STATUS "The value of CMAKE_SOURCE_DIR is: ${CMAKE_SOURCE_DIR}")
file(COPY ${CMAKE_SOURCE_DIR}/skynet/lualib/ DESTINATION pluto/lualib NO_SOURCE_PERMISSIONS)
file(COPY ${CMAKE_SOURCE_DIR}/skynet/test/ DESTINATION pluto/test NO_SOURCE_PERMISSIONS)
file(COPY ${CMAKE_SOURCE_DIR}/skynet/service/ DESTINATION pluto/service NO_SOURCE_PERMISSIONS)
file(COPY ${CMAKE_SOURCE_DIR}/skynet/examples/ DESTINATION pluto/examples NO_SOURCE_PERMISSIONS)
file(COPY ${CMAKE_SOURCE_DIR}/pluto/luaext/ DESTINATION pluto/luaext NO_SOURCE_PERMISSIONS)