-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathCMakeLists.txt
904 lines (807 loc) · 29.7 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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
# tried playing nice by using REQUIRE_QUIET but some built-in modules
# (CheckLibraryExists, ...) wouldn't listen so how about a nice cup
# of shut up.
function(message)
list(GET ARGV 0 TYPE)
if (TYPE STREQUAL "FATAL_ERROR")
list(REMOVE_AT ARGV 0)
_message(${TYPE} ${CL_RED} "${ARGV}" ${CL_RST})
endif()
endfunction()
function(amsg msg)
_message("" ${msg})
endfunction()
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
#cmake_policy(SET CMP0076 OLD)
if (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client")
PROJECT(arcan-libs)
else()
PROJECT(arcan)
endif()
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(CMAKE_C_STANDARD 11)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
set(EXTERNAL_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../external)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/platform/cmake/modules)
set(SHARED_PERMISSIONS
OWNER_WRITE OWNER_READ GROUP_WRITE GROUP_READ WORLD_READ)
set(SHARED_PERMISSIONS_DIR OWNER_WRITE OWNER_READ GROUP_WRITE
GROUP_READ WORLD_EXECUTE WORLD_READ)
# another hack to strip noisy / useless data away from message() abuse
include(ExternalProject)
include(CheckIncludeFiles)
find_package(PkgConfig REQUIRED)
find_package(Sanitizers REQUIRED)
# not pretty, but as a quick 'pending build system rewrite' thing
find_package(Threads REQUIRED)
find_package(Math REQUIRED)
find_package(RT REQUIRED)
find_package(DL REQUIRED)
find_package(Atomic REQUIRED)
set(STDLIB Threads::Threads Math::Math RT::RT DL::DL Atomic::Atomic)
if (CMAKE_COLOR_MAKEFILE)
include(CMakeColor)
endif()
if (GLOBAL_CFLAGS)
add_definitions(${GLOBAL_CFLAGS})
endif()
# static base version, manually mantained
set(MAJOR_VERSION 0)
set(MINOR_VERSION 7)
set(PATCH_LEVEL 0)
set(VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_LEVEL})
set(PLATFORM_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/platform)
set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/engine)
# distributions packaging a build should tag this accordingly so we
# can take that into consideration for bug reports
if (NOT DEFINED DISTR_TAG)
set(DISTR_TAG "unknown")
endif()
# generate an identifiable buildtag for tracking purposes
if (NOT DEFINED ENGINE_BUILDTAG)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.fslockout)
find_program(FOSSIL_EXECUTABLE NAMES fossil)
if (FOSSIL_EXECUTABLE)
execute_process(COMMAND ${FOSSIL_EXECUTABLE} describe
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE EXIT_CODE
OUTPUT_VARIABLE FOSSIL_VERSION
)
if (NOT ${EXIT_CODE} EQUAL 0)
set(ENGINE_BUILDTAG arcan-relukn-${VERSION})
else()
string(STRIP ${FOSSIL_VERSION} FOSSIL_VERSION)
set(ENGINE_BUILDTAG arcan-fossil-${FOSSIL_VERSION})
endif()
endif()
elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../git)
find_package(Git)
set(GIT_VERSION)
if (GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE EXIT_CODE
OUTPUT_VARIABLE GIT_VERSION
)
if (NOT ${EXIT_CODE} EQUAL 0)
else()
string(STRIP ${GIT_VERSION} GIT_VERSION)
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE EXIT_CODE
OUTPUT_VARIABLE GIT_BRANCH
)
if (NOT ${EXIT_CODE} EQUAL 0)
else()
string(STRIP ${GIT_BRANCH} GIT_BRANCH)
endif()
endif()
if (GIT_VERSION STREQUAL "")
amsg("${CL_RED}missing git_version, using 'relukn' for build tag${CL_RST}")
set(ENGINE_BUILDTAG arcan-relukn-${VERSION})
else()
set(ENGINE_BUILDTAG arcan-git-${GIT_BRANCH}-${GIT_VERSION})
endif()
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.fslckout)
execute_process(
COMMAND fossil info tip
COMMAND grep hash
COMMAND awk "{print substr($2, length($2)-6,6)}"
OUTPUT_VARIABLE FOSSIL_INFO
)
string(STRIP ${FOSSIL_INFO} FOSSIL_INFO)
set(ENGINE_BUILDTAG arcan-fossil-${FOSSIL_INFO}-${VERSION})
else()
amsg("${CL_RED}no scm found, using 'relukn' for build tag${CL_RST}")
set(ENGINE_BUILDTAG arcan-relukn-${VERSION})
endif()
endif()
set(SOURCE_TAG ${ENGINE_BUILDTAG})
set(ENGINE_BUILDTAG "")
set(SHARED_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
set(SHARED_PERMISSIONS_DIR OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
if (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client")
amsg("Client- Library only build, for docker containers and networked clients")
amsg("")
amsg("${CL_WHT}Optional library flags:${CL_RST}")
amsg("${CL_YEL}\t-DSHMIF_DISABLE_DEBUGIF=${CL_GRN}[Off|On]${CL_RST} - Remove server- controlled debug layer")
amsg("")
amsg("${CL_WHT}Optional arcan-net flags:${CL_RST}")
amsg("${CL_YEL}\t-DSTATIC_SQLite3=${CL_GRN}[Off|On]${CL_RST} - In-source SQLite3")
amsg("")
option(STATIC_SQLite3 "Use SQLite3 Amalgamation" OFF)
if (${CMAKE_SYSTEM_NAME} MATCHES "BSD|DragonFly")
set(BSD_BUILD TRUE)
set(EXTMAKE_CMD gmake)
endif()
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(VPLATFORM_STR "sdl2")
if (NOT VIDEO_PLATFORM)
set(VIDEO_PLATFORM "sdl2")
endif()
set(CMAKE_INSTALL_LIBDIR /usr/local/share/lib)
else()
set(VPLATFORM_STR "egl-dri, sdl2, egl-gles")
if (NOT VIDEO_PLATFORM)
set(VIDEO_PLATFORM "egl-dri")
endif()
include(GNUInstallDirs)
endif()
set(APLATFORM_STR "openal, stub")
set(AGPPLATFORM_STR "gl21, gles2, gles3, stub")
# we can remove some of this cruft when 'buntu LTS gets ~3.0ish
option(DISABLE_JIT "Don't use the luajit-5.1 VM (if found)" OFF)
option(STATIC_SQLite3 "Use SQLite3 Amalgamation" OFF)
option(STATIC_OPENAL "Use static OpenAL (external/git folder)" OFF)
option(STATIC_LIBUVC "Use static libuvc (external/git folder)" ON)
option(ENABLE_LTO "Build with Link-Time Optimization enabled" OFF)
option(ENABLE_LWA "Build LWA client (arcan-in-arcan)" ON)
option(ENABLE_SIMD "Build with SIMD vector instruction set support" ON)
option(ENABLE_SIMD_ALIGNED "Assert that SIMD data sources are 16-byte aligned" OFF)
option(ENABLE_TRACY "Build with Tracy client integration (external/git folder)" OFF)
option(DISABLE_WAYLAND "Never build wayland support" OFF)
option(HYBRID_SDL "Produce an arcan_sdl main binary as well" OFF)
option(HYBRID_HEADLESS "Produce a headless binary as well" OFF)
amsg("")
amsg("${CL_WHT}Build Presets:")
amsg("${CL_YEL}\t-DBUILD_PRESET=${CL_GRN}everything client${CL_RST}")
amsg("")
amsg("${CL_WHT}Audio/Video/Input Support:")
amsg("${CL_YEL}\t-DAUDIO_PLATFORM=${CL_GRN}${APLATFORM_STR}${CL_RST}")
amsg("${CL_YEL}\t-DVIDEO_PLATFORM=${CL_GRN}${VPLATFORM_STR}${CL_RST}")
amsg("${CL_YEL}\t-DAGP_PLATFORM=${CL_GRN}${AGPPLATFORM_STR}${CL_RST}")
amsg("")
amsg("${CL_WHT}VIDEO_PLATFORM=egl-dri options:${CL_RST}")
amsg("${CL_YEL}\t-DHYBRID_SDL=${CL_GRN}[Off|On]${CL_RST} - Enable arcan_sdl output build")
amsg("${CL_YEL}\t-DHYBRID_HEADLESS=${CL_GRN}[Off|On]${CL_RST} - Enable arcan_headless output build")
amsg("")
amsg("${CL_WHT}Cmake Options:${CL_RST}")
amsg("${CL_YEL}\t-DCMAKE_BUILD_TYPE=${CL_GRN}[Debug|Release|Profile|DebugTrace]")
amsg("${CL_YEL}\t-DENABLE_WALL_SPAM=${CL_GRN}[Off|On]${CL_RST} - More build warnings")
amsg("${CL_YEL}\t-DENABLE_SIMD=${CL_GRN}[On|Off]${CL_RST} - Enable SIMD optimized instructions")
# amsg(" -DENABLE_PBO=[Appl-path] : Profile-based Optimization prepass with appl")
# amsg(" as optimization profile.")
amsg("${CL_YEL}\t\t-DSIMD_ALIGNED=${CL_GRN}[Off|On]${CL_RST} - SIMD support assumes 16-byte alignment")
amsg("${CL_YEL}\t-DENABLE_LTO=${CL_GRN}[Off|On]${CL_RST} - Build with Link-Time Optimizations")
amsg("${CL_YEL}\t-DENABLE_TRACY=${CL_GRN}[Off|On]${CL_RST} - Build with Tracy integration")
amsg("")
amsg("${CL_WHT}Dependency Management:${CL_RST}")
amsg("${CL_YEL}\t-DSTATIC_SQLite3=${CL_GRN}[Off|On]${CL_RST} - In-source SQLite3")
amsg("${CL_YEL}\t-DSTATIC_OPENAL=${CL_GRN}[Off|On]${CL_RST} - In-source OpenAL, see external/README")
amsg("${CL_YEL}\t-DSTATIC_LIBUVC=${CL_GRN}[Off|On]${CL_RST} - In-source libuvc")
amsg("")
amsg("${CL_WHT}Optional engine flags:${CL_RST}")
amsg("${CL_YEL}\t-DENABLE_LWA=${CL_GRN}[Off|On]${CL_RST} - Build LWA Arcan client (nesting support)")
amsg("${CL_YEL}\t-DDISABLE_JIT=${CL_GRN}[Off|On]${CL_RST} - Don't Link with luajit51 (even if found)")
amsg("${CL_YEL}\t-DBUILTIN_LUA=${CL_GRN}[Off|On]${CL_RST} - Static build lua51 (with disable_jit)")
amsg("${CL_YEL}\t-DSHMIF_DISABLE_DEBUGIF=${CL_GRN}[Off|On]${CL_RST} - Remove server- controlled debug layer")
amsg("")
amsg("${CL_WHT}Frameserver flags:${CL_RST}")
amsg("${CL_WHT}Decode:${CL_RST}")
amsg("${CL_YEL}\t-DFSRV_DECODE_UVC=${CL_GRN}[Off|On]${CL_RST} - Add support for libuvc- USB video cameras")
amsg("${CL_WHT}Terminal:${CL_RST}")
amsg("${CL_YEL}\t-DFSRV_TERMINAL_NOEXEC=${CL_GRN}[Off|On]${CL_RST} - Lock down 'exec' path from scripts")
amsg("")
amsg("${CL_WHT}Install / Autodetection Overrides:${CL_RST}")
amsg("${CL_YEL}\t-D(DISABLE_FSRV_ (encode, decode, net, remoting, terminal, game)${CL_GRN}=ON${CL_RST}")
amsg("${CL_YEL}\t-D(APPL_DEST, RES_DEST, APIMAN_DEST, MAN_DEST, SCRIPTS_DEST)=${CL_GRN}/some/path${CL_RST}")
amsg("")
if (NOT DEFINED AUDIO_PLATFORM)
# no other audio platforms supported currently
set(AUDIO_PLATFORM "openal")
endif()
endif()
if (BUILD_PRESET STREQUAL "everything" AND NOT (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
set(VIDEO_PLATFORM "egl-dri")
set(HYBRID_SDL ON)
set(HYBRID_HEADLESS ON)
endif()
add_compile_options(-Wall)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT ENABLE_WALL_SPAM)
add_compile_options(
-Wno-missing-braces
-Wno-unused-function
-Wno-unused-value
-Wno-unused-variable
-Wno-unused-result
-Wformat=0
)
elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang" AND NOT ENABLE_WALL_SPAM)
add_compile_options(
-Wno-unknown-warning-option
-Wno-unused-const-variable
-Wno-unused-value
-Wno-missing-braces
-Wno-unused-function
-Wno-atomic-alignment
-Wno-unused-variable
-Wno-unused-result
-Wno-macro-redefined
)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Profile")
amsg("${CL_WHT}------------------*Profile Build*------------------${CL_RST}")
add_definitions(-pg)
set(CMAKE_EXE_LINKER_FLAGS "-pg")
endif(CMAKE_BUILD_TYPE STREQUAL "Profile")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
amsg("${CL_WHT}------------------*Debug Build*--------------------${CL_RST}\n")
amsg("${CL_WHT}Debug Specific Setting:${CL_YEL}")
amsg("\tLUA_TRACE_METHOD=${CL_RST}[${CL_GRN}off${CL_RST}|${CL_GRN}stderr${CL_RST}|${CL_GRN}coverage${CL_RST}]")
if (LUA_TRACE_METHOD STREQUAL "stderr")
set(LUA_TAG_MODE " trace-stderr")
list(APPEND ARCAN_DEFINITIONS LUA_TRACE_STDERR)
endif()
if (LUA_TRACE_METHOD STREQUAL "coverage" AND NOT (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client"))
set(LUA_TAG_MODE " trace-coverage")
list(APPEND ARCAN_DEFINITIONS LUA_TRACE_COVERAGE)
endif()
add_definitions(-g -g3 -ggdb -D_DEBUG -O0 -fno-omit-frame-pointer)
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "DebugTrace")
amsg("${CL_WHT}-------------- *Debug Tracing Build* --------------${CL_WHT}")
add_definitions(-g -D_DEBUG -DTRACE_ENABLE)
endif (CMAKE_BUILD_TYPE STREQUAL "DebugTrace")
if (ENABLE_LTO)
add_compile_options(-flto)
endif()
if (NOT VIDEO_PLATFORM AND NOT (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client"))
message(FATAL_ERROR "${CL_RED}Video Platform missing, see -DVIDEO_PLATFORM= above${CL_RST}")
endif()
if (NOT (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client"))
amsg("${CL_WHT}\n------------- Configuration Results ---------------${CL_RST}\n")
amsg("\n${CL_WHT}-- Stage 1: dependencies and configuration${CL_RST}")
endif()
set(EXTERNAL_DEFS
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD 1
LOG_UPLOAD 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_TEST 1
LOG_INSTALL 1
)
set (CMAKE_EXTERNAL_DEFS
CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
-DLIBTYPE=STATIC
)
if (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client")
find_package(Freetype REQUIRED QUIET)
set(FREETYPE_DEFAULT_LIBRARIES ${FREETYPE_LIBRARIES})
set(FREETYPE_DEFAULT_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
if (STATIC_SQLite3)
amsg("${CL_YEL}Building SQLite3 from external/sqlite mirror${CL_RST}")
add_library(sqlite3 STATIC ${EXTERNAL_SRC_DIR}/sqlite/sqlite3.c)
set_target_properties(sqlite3 PROPERTIES COMPILE_FLAGS "-Os")
set(SQLite3_INCLUDE_DIR ${EXTERNAL_SRC_DIR}/sqlite)
set(SQLite3_LIBRARIES sqlite3)
else()
find_package(SQLite3 REQUIRED QUIET)
endif()
set(INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/engine
${CMAKE_CURRENT_SOURCE_DIR}/platform
${FREETYPE_DEFAULT_INCLUDE_DIRS}
)
else()
find_package(Freetype REQUIRED QUIET)
set(FREETYPE_DEFAULT_LIBRARIES ${FREETYPE_LIBRARIES})
set(FREETYPE_DEFAULT_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
#
# the amalgamation is already included in the external/ tree sqlite3 use is
# primarily settings management and very limited amount of queries, size is
# more important here
#
if (STATIC_SQLite3)
amsg("${CL_YEL}Building SQLite3 from external/sqlite mirror${CL_RST}")
add_library(sqlite3 STATIC ${EXTERNAL_SRC_DIR}/sqlite/sqlite3.c)
set_target_properties(sqlite3 PROPERTIES COMPILE_FLAGS "-Os")
set(SQLite3_INCLUDE_DIR ${EXTERNAL_SRC_DIR}/sqlite)
set(SQLite3_LIBRARIES sqlite3)
else()
find_package(SQLite3 REQUIRED QUIET)
endif()
include(${PLATFORM_ROOT}/cmake/CMakeLists.AGP)
include(${PLATFORM_ROOT}/cmake/CMakeLists.Video)
include(${PLATFORM_ROOT}/cmake/CMakeLists.Audio)
set(EXTMAKE_CMD make)
# for the statically- linked external dependencies, we need to hint where
# we need the gmake rather than make system
if (${CMAKE_SYSTEM_NAME} MATCHES "BSD|DragonFly")
set(BSD_BUILD TRUE)
set(EXTMAKE_CMD gmake)
endif()
set(LUA_LINKTYPE "dynamic")
if (NOT DISABLE_JIT)
set(LUA_TAG "luajit51")
if (EXISTS ${EXTERNAL_SRC_DIR}/git/luajit)
ExternalProject_Add(luajitbuild
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/luajit
GIT_REPOSITORY "${EXTERNAL_SRC_DIR}/git/luajit"
CONFIGURE_COMMAND ""
GIT_TAG "v2.1.0-beta3"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND "${EXTMAKE_CMD}"
DEFAULT_CC=${CMAKE_C_COMPILER}
${EXTERNAL_DEFS}
)
add_library(luajit STATIC IMPORTED)
add_dependencies(luajit luajitbuild)
set_target_properties(luajit PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/luajit/src/libluajit.a")
set(LUA_LIBRARY luajit)
set(LUA_LIBRARIES ${LUA_LIBRARY})
set(LUA_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/luajit/src")
list(APPEND MAIN_DEPS luajit)
set(LUA_LINKTYPE "static")
else()
pkg_check_modules(LUA luajit REQUIRED)
find_library(LUA_LIBRARY NAMES ${LUA_LIBRARIES} PATHS ${LUA_LIBRARY_DIRS})
set(LUA_INCLUDE_DIR ${LUA_INCLUDE_DIRS})
set(LUA_LIBRARIES ${LUA_LINK_LIBRARIES})
endif()
endif()
if (NOT LUA_LIBRARY OR DISABLE_JIT)
set(LUA_TAG "lua51")
if (NOT BUILTIN_LUA)
find_package(Lua51 REQUIRED)
else()
add_subdirectory(${EXTERNAL_SRC_DIR}/lua ${CMAKE_CURRENT_BINARY_DIR}/lua)
set(LUA_INCLUDE_DIR ${EXTERNAL_SRC_DIR}/lua)
set(LUA_LIBRARIES lua51)
set(LUA_LINKTYPE "static")
endif()
endif()
LIST (APPEND
ARCAN_LIBRARIES
${FREETYPE_DEFAULT_LIBRARIES}
${LUA_LIBRARIES}
${SQLite3_LIBRARIES}
)
LIST (APPEND
INCLUDE_DIRS
${LUA_INCLUDE_DIR}
${LUA_INCLUDE_DIRS}
${FREETYPE_DEFAULT_INCLUDE_DIRS}
${SQLite3_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/platform
${EXTERNAL_SRC_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/engine
)
list (APPEND SOURCES
engine/arcan_event.c
engine/arcan_lua.c
engine/alt/nbio.c
engine/alt/support.c
engine/alt/types.c
engine/alt/trace.c
engine/arcan_main.c
engine/arcan_conductor.c
engine/arcan_db.c
engine/arcan_video.c
engine/arcan_renderfun.c
engine/arcan_3dbase.c
engine/arcan_math.c
engine/arcan_audio.c
engine/arcan_ttf.c
engine/arcan_img.c
engine/arcan_led.c
engine/arcan_led.h
engine/arcan_ffunc_lut.c
engine/arcan_ffunc_lut.h
engine/arcan_audioint.h
engine/arcan_event.h
engine/arcan_lua.h
engine/arcan_math.h
engine/arcan_3dbase.h
engine/arcan_video.h
engine/arcan_audio.h
engine/arcan_general.h
engine/arcan_db.h
engine/arcan_frameserver.h
engine/arcan_frameserver.c
engine/arcan_monitor.c
shmif/arcan_shmif_sub.c
engine/arcan_vr.h
engine/arcan_vr.c
engine/arcan_raster.c
platform/platform.h
platform/video_platform.h
shmif/tui/raster/pixelfont.c
)
# database tool is sqlite3 + libc so less need to work
# around with platform layers etc.
set (ARCANDB_SOURCES
tools/db/dbtool.c
engine/arcan_db.c
platform/posix/warning.c
platform/posix/dbpath.c
platform/stub/mem.c
)
if (ENABLE_SIMD)
find_package(SSE QUIET)
if (SSE_FOUND)
if (SIMD_ALIGNED)
set_property(SOURCE engine/arcan_math_simd.c
APPEND PROPERTY COMPILE_DEFINITIONS ARCAN_MATH_ALIGNED_SIMD)
endif()
set_property(SOURCE engine/arcan_math.c
APPEND PROPERTY COMPILE_DEFINITIONS ARCAN_MATH_SIMD)
list(APPEND SOURCES engine/arcan_math_simd.c)
set_property(SOURCE engine/arcan_math_simd.c
APPEND PROPERTY COMPILE_FLAGS -msse3)
endif()
endif()
endif()
#
# Expand with more platforms as needed, all are expected to define PLATFORM_[
# ,fsrv, shmif]_SOURCES, add a global definition for PLATFORM_HEADER add any
# OS- specific definitions to ARCAN_LIBRARIES, set OS_DYLIB_EXTENSION
#
if (BSD_BUILD)
include(${CMAKE_CURRENT_SOURCE_DIR}/platform/cmake/CMakeLists.BSD)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
include(${CMAKE_CURRENT_SOURCE_DIR}/platform/cmake/CMakeLists.Linux)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
message(FATAL_ERROR "Windows is no longer supported (rollback to 0.4)")
#
# include(${CMAKE_CURRENT_SOURCE_DIR}/platform/cmake/CMakeLists.Windows)
#
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include(${CMAKE_CURRENT_SOURCE_DIR}/platform/cmake/CMakeLists.Darwin)
# OSX with CMAKE_OSX_SYSROOT set requires additional flags
set (COMPILER
"CC=${CMAKE_C_COMPILER} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}"
"CXX=${CMAKE_CXX_COMPILER} ${CMAKE_CXX_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}"
)
else()
message(FATAL_ERROR "${CL_RED}Unsupported OS(${CMAKE_SYSTEM_NAME}) detected, abandon ship!${CL_RST}")
endif()
# XKB might be necessary to deal with nested clients of all platform types
# and near necessary for wayland and x11 clients.
pkg_check_modules(XKB QUIET xkbcommon)
if (XKB_FOUND)
amsg("${CL_YEL}xkb keyboard: \t${CL_GRN}libxkbcommon${CL_RST}")
list(APPEND ARCAN_DEFINITIONS HAVE_XKBCOMMON)
list(APPEND ARCAN_LIBRARIES ${XKB_LINK_LIBRARIES})
list(APPEND INCLUDE_DIRS ${XKB_INCLUDE_DIRS})
else()
amsg("${CL_YEL}xkb keyboard: \t${CL_RED}no libxkbcommon${CL_RST}")
endif()
if (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client")
set(AGP_PLATFORM "stub")
else()
amsg("\n${CL_WHT}---- Configuration results:${CL_RST}")
amsg("${CL_YEL}compiler\t${CL_GRN}${CMAKE_C_COMPILER_ID}${CL_RST}")
amsg("${CL_YEL}video \t${CL_GRN}${VIDEO_PLATFORM}${CL_RST}")
if (HYBRID_SDL)
amsg("\t \t${CL_GRN}+support sdl platform${CL_RST}")
endif()
if (HYBRID_HEADLESS)
amsg("\t \t${CL_GRN}+support headless platform${CL_RST}")
endif()
amsg("${CL_YEL}accel \t${CL_GRN}${AGP_PLATFORM}${CL_RST}")
amsg("${CL_YEL}audio \t${CL_GRN}${AUDIO_PLATFORM}${CL_RST}")
amsg("${CL_YEL}input \t${CL_GRN}${INPUT_PLATFORM}${CL_RST}")
amsg("${CL_YEL}headless\t${CL_GRN}${LWA_PLATFORM_STR}${CL_RST}")
amsg("${CL_YEL}lua \t${CL_GRN}${LUA_TAG}${LUA_TAG_MODE} ${LUA_LINKTYPE}${CL_RST}")
amsg("\n${CL_WHT}-- Stage 2, Frameservers and external clients ${CL_RST}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
if (ENABLE_TRACY)
option(TRACY_ENABLE "" ON)
option(TRACY_ON_DEMAND "" ON)
option(TRACY_NO_CRASH_HANDLER "" ON)
option(TRACY_LIBUNWIND_BACKTRACE "" ON)
option(TRACY_HAS_CALLSTACK "" ON)
add_subdirectory(
${EXTERNAL_SRC_DIR}/git/tracy
${CMAKE_CURRENT_BINARY_DIR}/tracy
)
list(APPEND SOURCES engine/arcan_trace_tracy.cpp)
list(APPEND ARCAN_DEFINITIONS WITH_TRACY)
list(APPEND ARCAN_LIBRARIES
TracyClient
)
amsg("${CL_YEL}tracy support\t${CL_GRN}enabled${CL_RST}")
else()
list(APPEND SOURCES engine/arcan_trace.c)
amsg("${CL_YEL}tracy support\t${CL_RED}disabled${CL_RST}")
endif()
set(SHMIF_TUI true)
add_subdirectory(shmif)
add_subdirectory(a12)
if (NOT (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client"))
add_subdirectory(wayland)
endif()
include_directories(${ARCAN_SHMIF_INCLUDE_DIR})
if (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client")
# build the terminal emulator as well as that is typically useful
set(DISABLE_FSRV_GAME TRUE)
set(DISABLE_FSRV_DECODE TRUE)
set(DISABLE_FSRV_NET TRUE)
set(DISABLE_FSRV_ENCODE TRUE)
set(DISABLE_FSRV_REMOTING TRUE)
set(DISABLE_FSRV_AVFEED TRUE)
add_subdirectory(frameserver)
set(BIN_INSTALL)
else()
add_subdirectory(frameserver)
if (EXISTS ${EXTERNAL_SRC_DIR}/git/openal)
if(ENABLE_LWA AND LWA_PLATFORM_STR)
amsg("\n${CL_WHT}-- Stage 3, LWA Build${CL_RST}")
include(platform/cmake/CMakeLists.LWA)
else()
amsg("\n${CL_WHT}-- Stage 3, LWA Build (omitted)${CL_RST}")
endif()
else()
amsg("\n${CL_WHT}-- Stage 3, LWA Build (omitted, see external/README)${CL_RST}")
endif()
amsg("\n${CL_WHT}-- Stage 4, Linking / Packaging (=>${CMAKE_INSTALL_PREFIX})${CL_RST}")
add_executable(arcan
${SOURCES}
${ARCAN_PLATFORM}
${AGP_SOURCES}
${PLATFORM_SOURCES}
${VIDEO_PLATFORM_SOURCES}
${AUDIO_PLATFORM_SOURCES}
${PLATFORM_ROOT}/${INPUT_PLATFORM}/event.c
)
add_sanitizers(arcan)
set(BIN_INSTALL)
if (${FRAMESERVER_MODESTRING})
string(STRIP ${FRAMESERVER_MODESTRING} FRAMESERVER_MODESTRING)
endif()
set(PLATFORM_BUILDTAG ${VIDEO_PLATFORM}-${AGP_PLATFORM}-${AUDIO_PLATFORM}-${INPUT_PLATFORM}-${LUA_TAG}-${DISTR_TAG})
target_include_directories(arcan PRIVATE ${INCLUDE_DIRS})
target_compile_definitions(arcan PRIVATE
${ARCAN_DEFINITIONS}
${ARCAN_NOLWA_DEFINITIONS}
${PLATFORM_DEFINITIONS}
ARCAN_BUILDVERSION=\"${SOURCE_TAG}-${PLATFORM_BUILDTAG}-${CMAKE_SYSTEM_NAME}\"
FRAMESERVER_MODESTRING=\"${FRAMESERVER_MODESTRING}\"
)
target_link_libraries(arcan
${STDLIB}
${ARCAN_LIBRARIES}
${VIDEO_LIBRARIES}
${AUDIO_LIBRARIES}
${AGP_LIBRARIES}
arcan_shmif_int
arcan_tui
)
# Primarily used by the Darwin platform, since it is scanned before we
# have the targets defined, we expose and add the property here
if (ARCAN_LNK_FLAGS)
set_property(TARGET arcan APPEND PROPERTY LINK_FLAGS ${ARCAN_LNK_FLAGS})
endif()
if (MAIN_DEPS)
add_dependencies(arcan ${MAIN_DEPS})
endif()
# Hybrid build is to allow the platform combination of egl-dri main with
# fallback to SDL if X11 or Wayland is detected. We do this by resetting
# and reusing the probe stage. It's not pretty, but beats a redesign.
# Some cleanup possible by defining a function for taking [a,v,e,o] and
# storing into a source/include/lib dir so that we can do that for both
# arcan, the hybrids and lwa at the same time.
if(VIDEO_PLATFORM STREQUAL "egl-dri")
if(HYBRID_SDL)
set_property(
SOURCE engine/arcan_main.c
APPEND PROPERTY COMPILE_DEFINITIONS
ARCAN_HYBRID_SDL=1
)
amsg("-- Appending sdl platform build--")
set(VIDEO_PLATFORM "sdl2")
set(INPUT_PLATFORM "sdl2")
set(PLATFORM_DEFINITIONS "")
set(VIDEO_PLATFORM_SOURCES "")
set(AUDIO_PLATFORM_SOURCES "")
set(INPUT_PLATFORM_SOURCES "")
# HACK: Force- remove the psep-open from the platform and switch to the open
list(FIND ARCAN_PLATFORM "${PLATFORM_ROOT}/posix/psep_open.c" _index)
if (${_index} GREATER -1)
list(REMOVE_AT ARCAN_PLATFORM ${_index})
list(APPEND ARCAN_PLATFORM ${PLATFORM_ROOT}/posix/open.c)
endif()
include(${PLATFORM_ROOT}/cmake/CMakeLists.Video)
include(${PLATFORM_ROOT}/cmake/CMakeLists.Audio)
add_executable(arcan_sdl
${SOURCES}
${ARCAN_PLATFORM}
${AGP_SOURCES}
${PLATFORM_SOURCES}
${VIDEO_PLATFORM_SOURCES}
${AUDIO_PLATFORM_SOURCES}
${PLATFORM_ROOT}/sdl2/event.c
)
if (MAIN_DEPS)
add_dependencies(arcan_sdl ${MAIN_DEPS})
endif()
target_include_directories(arcan_sdl PRIVATE ${INCLUDE_DIRS})
set(PLATFORM_BUILDTAG sdl2-${AGP_PLATFORM}-sdl2-sdl2-${LUA_TAG}-${DISTR_TAG})
target_compile_definitions(arcan_sdl PRIVATE
${ARCAN_DEFINITIONS}
${ARCAN_NOLWA_DEFINITIONS}
${PLATFORM_DEFINITIONS}
ARCAN_BUILDVERSION=\"${SOURCE_TAG}-${PLATFORM_BUILDTAG}-${CMAKE_SYSTEM_NAME}\"
FRAMESERVER_MODESTRING=\"${FRAMESERVER_MODESTRING}\"
)
target_link_libraries(arcan_sdl
${STDLIB} ${ARCAN_LIBRARIES} ${VIDEO_LIBRARIES} ${AUDIO_LIBRARIES}
${AGP_LIBRARIES} arcan_shmif_int arcan_tui
)
list(APPEND BIN_INSTALL arcan_sdl)
endif()
# Hybrid headless is to allow an arcan setup where the normal egl drivers
# etc. are being used, but the input platform is exposed as an connection
# point in order to use it as a render server or client 'host' for remote
# desktop like situations.
if (HYBRID_HEADLESS)
amsg("-- Appending headless platform build--")
set(VIDEO_PLATFORM headless)
set(ARCAN_DEFINITIONS "")
include(${PLATFORM_ROOT}/cmake/CMakeLists.Video)
# HACK: Force- remove the psep-open from the platform and switch to the open
list(FIND ARCAN_PLATFORM "${PLATFORM_ROOT}/posix/psep_open.c" _index)
if (${_index} GREATER -1)
list(REMOVE_AT ARCAN_PLATFORM ${_index})
list(APPEND ARCAN_PLATFORM ${PLATFORM_ROOT}/posix/open.c)
endif()
list(APPEND BIN_INSTALL arcan_headless)
add_executable(arcan_headless
${SOURCES}
${ARCAN_PLATFORM}
${AGP_SOURCES}
${PLATFORM_SOURCES}
${VIDEO_PLATFORM_SOURCES}
${AUDIO_PLATFORM_SOURCES}
${PLATFORM_ROOT}/headless/event.c
)
if (MAIN_DEPS)
add_dependencies(arcan_headless ${MAIN_DEPS})
endif()
target_include_directories(arcan_headless PRIVATE ${INCLUDE_DIRS})
set(PLATFORM_BUILDTAG headless-${AGP_PLATFORM}-${AUDIO_PLATFORM}-headless-${LUA_TAG}-${DISTR_TAG})
target_compile_definitions(arcan_headless PRIVATE
${ARCAN_DEFINITIONS}
${ARCAN_NOLWA_DEFINITIONS}
${PLATFORM_DEFINITIONS}
ARCAN_HEADLESS
FRAMESERVER_MODESTRING=\"${FRAMESERVER_MODESTRING}\"
ARCAN_BUILDVERSION=\"${SOURCE_TAG}-${PLATFORM_BUILDTAG}-${CMAKE_SYSTEM_NAME}\"
)
target_link_libraries(arcan_headless
${STDLIB} ${ARCAN_LIBRARIES} ${VIDEO_LIBRARIES} ${AUDIO_LIBRARIES}
${AGP_LIBRARIES} arcan_shmif_int arcan_tui
)
list(APPEND BIN_INSTALL arcan_headless)
endif()
set(VIDEO_PLATFORM egl-dri)
endif() #egl-dri
#
# The database tool is a CLI for the engine/arcan_db with additional
# code not part of the main arcan binaries (to make it somewhat harder
# for a misbehaving script to add / introduce new configs / targets
# and execute them.
#
add_executable(arcan_db ${ARCANDB_SOURCES})
add_sanitizers(arcan_db)
target_link_libraries(arcan_db ${STDLIB} ${SQLite3_LIBRARIES})
target_include_directories(arcan_db PRIVATE ${INCLUDE_DIRS})
target_compile_definitions(arcan_db PRIVATE ARCAN_DB_STANDALONE)
list(APPEND BIN_INSTALL arcan_db)
#
# Special case, the egl-dri platform requires suid- for the chain-loader
#
#
if (VIDEO_PLATFORM STREQUAL "egl-dri")
amsg("${CL_YEL}egl-dri+privsep${CL_RST}\t${CL_GRN}installing SUID${CL_RST}")
install(TARGETS arcan DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS
SETUID
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
else()
install(TARGETS arcan DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ${BIN_INSTALL} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/../data/appl
DESTINATION ${APPL_DEST}
DIRECTORY_PERMISSIONS ${SHARED_PERMISSONS_DIR}
FILE_PERMISSIONS ${SHARED_PERMISSIONS}
PATTERN ".gitignore" EXCLUDE
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/../data/scripts
DESTINATION ${SCRIPTS_DEST}
DIRECTORY_PERMISSIONS ${SHARED_PERMISSIONS_DIR}
FILE_PERMISSIONS ${SHARED_PERMISSIONS}
PATTERN ".gitignore" EXCLUDE
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/../data/resources
DESTINATION ${RES_DEST}
DIRECTORY_PERMISSIONS ${SHARED_PERMISSIONS_DIR}
FILE_PERMISSIONS ${SHARED_PERMISSIONS}
PATTERN ".gitignore" EXCLUDE
)
if (MAN_DEST)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/../doc/arcan.1
${CMAKE_CURRENT_SOURCE_DIR}/../doc/arcan_db.1
DESTINATION ${MAN_DEST}
PERMISSIONS ${SHARED_PERMISSONS}
)
endif()
endif()
configure_file(${PLATFORM_ROOT}/cmake/shmif.pc.in
${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
if (NOT (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client"))
configure_file(${PLATFORM_ROOT}/cmake/shmif_ext.pc.in
${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif-ext.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif-ext.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
configure_file(${PLATFORM_ROOT}/cmake/shmif_tui.pc.in
${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif-tui.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif-tui.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
configure_file(${PLATFORM_ROOT}/cmake/shmif_srv.pc.in
${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif-srv.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/arcan-shmif-srv.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
if (NOT (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client"))
#
# Only installed if they have been generated manually, this is rather
# suboptimal -- possibly replace with a compile- time option and a probe
# for the correct ruby version
#
if (APIMAN_DEST AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../doc/mantmp)
amsg("${CL_YEL}API- manpages\t${CL_GRN}mantmp found")
file(GLOB MANTMP ${CMAKE_CURRENT_SOURCE_DIR}/../doc/mantmp/*.3)
install(FILES
${MANTMP}
DESTINATION ${APIMAN_DEST}
PERMISSIONS ${SHARED_PERMISSIONS}
)
else()
amsg("${CL_YEL}API- manpages\t${CL_RED}no mantmp, run ruby docgen.rb in arcan/doc${CL_RST}")
endif()
amsg("${CL_RST}")
endif()