-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
2357 lines (2015 loc) · 84.9 KB
/
Copy pathCMakeLists.txt
File metadata and controls
2357 lines (2015 loc) · 84.9 KB
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
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required(VERSION 3.20)
# ====================================================================
# Vix.cpp — Umbrella CMake Configuration
# ====================================================================
# Purpose:
# - Build Vix modules (json, utils, core, websocket, orm, cli).
# - Provide a single umbrella target: vix::vix
# - Install/export a CMake package: find_package(Vix CONFIG REQUIRED)
#
# Quick start:
# cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DVIX_BUILD_EXAMPLES=ON
# cmake --build build -j
# ====================================================================
# Policies for newer CMake versions
if (POLICY CMP0126)
cmake_policy(SET CMP0126 NEW)
endif()
if (POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
# Resolve umbrella version from git (preferred)
set(_VIX_VERSION_FALLBACK "0.0.0")
find_package(Git QUIET)
set(_VIX_GIT_DESCRIBE "")
if(Git_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --tags --always --dirty
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE _VIX_GIT_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
# Compute PROJECT_VERSION (must be numeric for CMake packaging)
# If describe returns: v1.20.1-4-gXXXX -> numeric is 1.20.1
set(_VIX_PROJECT_VERSION "${_VIX_VERSION_FALLBACK}")
if(_VIX_GIT_DESCRIBE MATCHES "^v([0-9]+\\.[0-9]+\\.[0-9]+)")
set(_VIX_PROJECT_VERSION "${CMAKE_MATCH_1}")
endif()
project(vix VERSION ${_VIX_PROJECT_VERSION} LANGUAGES CXX)
set(VIX_SDK_PROFILE "" CACHE STRING "SDK profile to build (empty/legacy/default/web/data/desktop/p2p/game/agent/all)")
set_property(CACHE VIX_SDK_PROFILE PROPERTY STRINGS
"" legacy default web data desktop p2p game agent all
)
set(_VIX_SDK_PROFILE_EFFECTIVE "${VIX_SDK_PROFILE}")
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "")
set(_VIX_SDK_PROFILE_EFFECTIVE "legacy")
endif()
string(TOLOWER "${_VIX_SDK_PROFILE_EFFECTIVE}" _VIX_SDK_PROFILE_EFFECTIVE)
set(_VIX_SDK_PROFILE_NAMES legacy default web data desktop p2p game agent all)
if (NOT _VIX_SDK_PROFILE_EFFECTIVE IN_LIST _VIX_SDK_PROFILE_NAMES)
message(FATAL_ERROR
"Unknown VIX_SDK_PROFILE=${VIX_SDK_PROFILE}. "
"Expected one of: legacy, default, web, data, desktop, p2p, game, agent, all."
)
endif()
set(_VIX_SDK_PROFILE_OPTION_VARS
VIX_ENABLE_ORM
VIX_ENABLE_WEBSOCKET
VIX_ENABLE_CLI
VIX_ENABLE_MIDDLEWARE
VIX_ENABLE_HTTP_COMPRESSION
VIX_ENABLE_DB
VIX_DB_USE_MYSQL
VIX_DB_USE_SQLITE
VIX_DB_USE_POSTGRES
VIX_DB_USE_REDIS
VIX_ENABLE_P2P
VIX_ENABLE_P2P_HTTP
VIX_ENABLE_CACHE
VIX_ENABLE_ASYNC
VIX_ENABLE_VALIDATION
VIX_ENABLE_CRYPTO
VIX_ENABLE_WEBRPC
VIX_ENABLE_REQUESTS
VIX_ENABLE_REALTIME
VIX_ENABLE_TIME
VIX_ENABLE_TESTS_MODULE
VIX_ENABLE_TEMPLATE
VIX_ENABLE_UI
VIX_UI_ENABLE_LINUX_WEBVIEW
VIX_CLI_ENABLE_DESKTOP
VIX_ENABLE_NOTE
VIX_ENABLE_PROCESS
VIX_ENABLE_ENGINE
VIX_ENABLE_THREADPOOL
VIX_ENABLE_KV
VIX_ENABLE_AGENT
VIX_ENABLE_GAME
VIX_GAME_ENABLE_SDL
VIX_GAME_ENABLE_SDL_OPENGL
)
set(_VIX_SDK_PROFILE_USER_CACHE_VARS)
foreach(_vix_sdk_profile_var IN LISTS _VIX_SDK_PROFILE_OPTION_VARS)
if (DEFINED CACHE{${_vix_sdk_profile_var}})
get_property(_vix_sdk_profile_cache_help CACHE ${_vix_sdk_profile_var} PROPERTY HELPSTRING)
if (NOT _vix_sdk_profile_cache_help MATCHES "^Set by VIX_SDK_PROFILE=")
list(APPEND _VIX_SDK_PROFILE_USER_CACHE_VARS "${_vix_sdk_profile_var}")
endif()
endif()
endforeach()
if (WIN32)
add_compile_definitions(
_WIN32_WINNT=0x0A00
WIN32_LEAN_AND_MEAN
NOMINMAX
)
endif()
# Human-friendly version string (can include -N-gHASH[-dirty])
if(_VIX_GIT_DESCRIBE STREQUAL "")
set(VIX_UMBRELLA_VERSION "v${PROJECT_VERSION}")
else()
set(VIX_UMBRELLA_VERSION "${_VIX_GIT_DESCRIBE}")
endif()
set(VIX_UMBRELLA_VERSION "${VIX_UMBRELLA_VERSION}" CACHE STRING "Umbrella version" FORCE)
set(VIX_UMBRELLA_BUILD ON CACHE BOOL "Building Vix from umbrella" FORCE)
# Make find_package honor *_ROOT hints (e.g. MYSQLCPPCONN_ROOT)
if (POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(FetchContent)
# Resolve to a real target (not an ALIAS) so we can mutate properties safely.
function(vix_resolve_real_target out name)
set(_real "")
if (TARGET "${name}")
get_target_property(_aliased "${name}" ALIASED_TARGET)
if (_aliased)
set(_real "${_aliased}")
else()
set(_real "${name}")
endif()
endif()
set(${out} "${_real}" PARENT_SCOPE)
endfunction()
# Apply sanitizer flags to a real local target only.
function(vix_enable_sanitizers target)
if (NOT VIX_ENABLE_SANITIZERS)
return()
endif()
if (NOT TARGET "${target}")
return()
endif()
get_target_property(_target_type "${target}" TYPE)
if (NOT _target_type)
return()
endif()
# INTERFACE libraries do not compile or link anything themselves.
# Sanitizer flags must not be applied to them.
if (_target_type STREQUAL "INTERFACE_LIBRARY")
message(STATUS "Sanitizers: skipping interface target '${target}'")
return()
endif()
if (MSVC)
message(FATAL_ERROR "Sanitizers are not supported on MSVC. Use Clang or GCC.")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(${target} PRIVATE
-O1
-g
-fno-omit-frame-pointer
-fsanitize=address,undefined
)
target_link_options(${target} PRIVATE
-fsanitize=address,undefined
)
endif()
endfunction()
# Resolve the first existing target name among candidates, then apply sanitizers.
function(vix_enable_sanitizers_first)
foreach(_candidate IN LISTS ARGN)
if (TARGET "${_candidate}")
get_target_property(_aliased "${_candidate}" ALIASED_TARGET)
if (_aliased)
vix_enable_sanitizers("${_aliased}")
else()
vix_enable_sanitizers("${_candidate}")
endif()
return()
endif()
endforeach()
endfunction()
# RPATH to easily run after installation
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()
# ----------------------------------------------------
# Global build settings
# ----------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Copy compile_commands.json to repo root (tooling QoL)
# Disabled on Windows because Visual Studio generators do not reliably
# generate compile_commands.json and this must never fail a build.
if (NOT WIN32)
if (CMAKE_EXPORT_COMPILE_COMMANDS)
add_custom_target(copy-compile-commands ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_BINARY_DIR}/compile_commands.json"
"${CMAKE_SOURCE_DIR}/compile_commands.json"
BYPRODUCTS "${CMAKE_SOURCE_DIR}/compile_commands.json"
COMMENT "Copy compile_commands.json to project root"
VERBATIM
)
endif()
else()
message(STATUS "compile_commands.json copy disabled on Windows.")
endif()
# ----------------------------------------------------
# Options
# ----------------------------------------------------
option(VIX_ENABLE_WARNINGS "Enable extra warnings" ON)
option(VIX_ENABLE_INSTALL "Enable install/export rules for packaging" ON)
option(VIX_ENABLE_LTO "Enable IPO/LTO (Release only)" OFF)
option(VIX_MSVC_STATIC_RUNTIME "Link MSVC runtime statically (/MT)" OFF)
option(VIX_ENABLE_CLANG_TIDY "Enable clang-tidy if available" OFF)
option(VIX_ENABLE_CPPCHECK "Enable cppcheck if available" OFF)
option(VIX_ENABLE_COVERAGE "Enable coverage flags (Debug only)" OFF)
option(VIX_ENABLE_SANITIZERS "Enable ASan+UBSan (GCC/Clang only)" OFF)
option(VIX_BUILD_EXAMPLES "Build umbrella examples in ./examples" ON)
option(VIX_BUILD_TESTS "Build unit tests (GoogleTest)" OFF)
option(VIX_ENABLE_ORM "Build Vix ORM module" ON)
option(VIX_ENABLE_WEBSOCKET "Build Vix WebSocket module" ON)
option(VIX_ENABLE_CLI "Build Vix CLI module" ON)
option(VIX_FORCE_FETCH_JSON "Fetch JSON backend if modules/json missing" ON)
option(VIX_BENCH_MODE "Disable heavy security/logging checks for benchmarks" OFF)
option(VIX_ENABLE_MIDDLEWARE "Build Vix middleware module" ON)
option(VIX_ENABLE_HTTP_COMPRESSION "Enable HTTP compression middleware deps (zlib/brotli)" ON)
option(VIX_ENABLE_DB "Build Vix DB module (core anti-ORM)" ON)
option(VIX_DB_USE_MYSQL "Enable MySQL backend in vix_db" ON)
option(VIX_DB_USE_SQLITE "Enable SQLite backend in vix_db" OFF)
option(VIX_DB_USE_POSTGRES "Enable PostgreSQL backend in vix_db" OFF)
option(VIX_DB_USE_REDIS "Enable Redis backend in vix_db" OFF)
option(VIX_ENABLE_P2P "Build Vix P2P module" ON)
option(VIX_ENABLE_P2P_HTTP "Build Vix P2P HTTP adapter module" ON)
option(VIX_ENABLE_CACHE "Build Vix Cache module" ON)
option(VIX_FETCH_DEPS "Allow fetching missing deps from the internet" OFF)
option(VIX_ENABLE_ASYNC "Build Vix Async module" ON)
option(VIX_ENABLE_VALIDATION "Build Vix Validation module" ON)
option(VIX_ENABLE_CRYPTO "Build Vix Crypto module" ON)
option(VIX_ENABLE_WEBRPC "Build Vix WebRPC module" ON)
option(VIX_ENABLE_REQUESTS "Build Vix Requests module" ON)
option(VIX_ENABLE_REALTIME "Build Vix Realtime module" ON)
option(VIX_REALTIME_BUILD_TESTS "Build vix::realtime tests" ${VIX_BUILD_TESTS})
option(VIX_REALTIME_BUILD_EXAMPLES "Build vix::realtime examples" OFF)
option(VIX_REALTIME_WITH_WEBSOCKET "Build vix::realtime WebSocket transport adapter" ${VIX_ENABLE_WEBSOCKET})
option(VIX_REALTIME_WITH_POSTGRES "Build vix::realtime PostgreSQL stores" OFF)
option(VIX_REQUESTS_BUILD_TESTS "Build vix::requests tests" ${VIX_BUILD_TESTS})
option(VIX_REQUESTS_BUILD_EXAMPLES "Build vix::requests examples" OFF)
option(VIX_ENABLE_TIME "Build Vix Time module" ON)
option(VIX_TIME_BUILD_TESTS "Build vix::time tests" ${VIX_BUILD_TESTS})
option(VIX_TIME_BUILD_BENCH "Build vix::time benchmarks" OFF)
option(VIX_ENABLE_TESTS_MODULE "Build Vix Tests module" ON)
option(VIX_ENABLE_TEMPLATE "Build Vix Template module" ON)
option(VIX_TEMPLATE_BUILD_TESTS "Build vix::template tests" ${VIX_BUILD_TESTS})
option(VIX_TEMPLATE_BUILD_EXAMPLES "Build vix::template examples" OFF)
option(VIX_TEMPLATE_BUILD_BENCH "Build vix::template benchmarks" OFF)
option(VIX_ENABLE_UI "Build Vix UI module" ON)
option(VIX_UI_BUILD_TESTS "Build vix::ui tests" ${VIX_BUILD_TESTS})
option(VIX_UI_BUILD_EXAMPLES "Build vix::ui examples" OFF)
option(VIX_UI_BUILD_BENCHMARKS "Build vix::ui benchmarks" OFF)
option(VIX_UI_ENABLE_LINUX_WEBVIEW "Enable Linux desktop WebView backend for vix::ui" OFF)
option(VIX_CLI_ENABLE_DESKTOP "Build vix desktop CLI support through vix::ui" ${VIX_ENABLE_UI})
option(VIX_ENABLE_NOTE "Build Vix Note module" ON)
option(VIX_NOTE_BUILD_TESTS "Build vix::note tests" ${VIX_BUILD_TESTS})
option(VIX_NOTE_BUILD_EXAMPLES "Build vix::note examples" OFF)
option(VIX_ENABLE_PROCESS "Build Vix Process module" ON)
option(VIX_ENABLE_ENGINE "Build Vix Engine module" ON)
option(VIX_ENABLE_THREADPOOL "Build Vix ThreadPool module" ON)
option(VIX_THREADPOOL_BUILD_EXAMPLES "Build vix::threadpool examples" OFF)
option(VIX_THREADPOOL_BUILD_TESTS "Build vix::threadpool tests" ${VIX_BUILD_TESTS})
option(VIX_THREADPOOL_BUILD_BENCHMARKS "Build vix::threadpool benchmarks" OFF)
option(VIX_ENABLE_KV "Build Vix KV module" ON)
option(VIX_KV_BUILD_EXAMPLES "Build vix::kv examples" OFF)
option(VIX_KV_BUILD_TESTS "Build vix::kv tests" ${VIX_BUILD_TESTS})
option(VIX_KV_BUILD_BENCHMARKS "Build vix::kv benchmarks" OFF)
option(VIX_ENABLE_AGENT "Build Vix AI Agent module" ON)
option(VIX_AGENT_BUILD_TESTS "Build vix::ai_agent tests" ${VIX_BUILD_TESTS})
option(VIX_AGENT_BUILD_EXAMPLES "Build vix::ai_agent examples" OFF)
option(VIX_ENABLE_GAME "Build Vix Game module" ON)
option(VIX_GAME_BUILD_TESTS "Build vix::game tests" ${VIX_BUILD_TESTS})
option(VIX_GAME_BUILD_EXAMPLES "Build vix::game examples" OFF)
option(VIX_GAME_ENABLE_SDL "Enable SDL backend for vix::game" OFF)
option(VIX_GAME_ENABLE_SDL_OPENGL "Enable SDL OpenGL renderer backend for vix::game" OFF)
option(VIX_ORM_BUILD_EXAMPLES "Build vix::orm examples" OFF)
option(VIX_ORM_BUILD_TESTS "Build vix::orm tests" ${VIX_BUILD_TESTS})
function(vix_sdk_profile_default option_name option_value)
list(FIND _VIX_SDK_PROFILE_USER_CACHE_VARS "${option_name}" _vix_sdk_profile_user_index)
if (_vix_sdk_profile_user_index EQUAL -1)
set(${option_name} ${option_value} CACHE BOOL "Set by VIX_SDK_PROFILE=${_VIX_SDK_PROFILE_EFFECTIVE}" FORCE)
endif()
endfunction()
function(vix_sdk_profile_common)
vix_sdk_profile_default(VIX_ENABLE_ORM OFF)
vix_sdk_profile_default(VIX_ENABLE_WEBSOCKET OFF)
vix_sdk_profile_default(VIX_ENABLE_CLI ON)
vix_sdk_profile_default(VIX_ENABLE_MIDDLEWARE OFF)
vix_sdk_profile_default(VIX_ENABLE_DB OFF)
vix_sdk_profile_default(VIX_DB_USE_MYSQL OFF)
vix_sdk_profile_default(VIX_DB_USE_SQLITE OFF)
vix_sdk_profile_default(VIX_DB_USE_POSTGRES OFF)
vix_sdk_profile_default(VIX_DB_USE_REDIS OFF)
vix_sdk_profile_default(VIX_ENABLE_P2P OFF)
vix_sdk_profile_default(VIX_ENABLE_P2P_HTTP OFF)
vix_sdk_profile_default(VIX_ENABLE_CACHE OFF)
vix_sdk_profile_default(VIX_ENABLE_ASYNC ON)
vix_sdk_profile_default(VIX_ENABLE_VALIDATION OFF)
vix_sdk_profile_default(VIX_ENABLE_CRYPTO OFF)
vix_sdk_profile_default(VIX_ENABLE_WEBRPC OFF)
vix_sdk_profile_default(VIX_ENABLE_REQUESTS OFF)
vix_sdk_profile_default(VIX_ENABLE_REALTIME OFF)
vix_sdk_profile_default(VIX_ENABLE_TIME ON)
vix_sdk_profile_default(VIX_ENABLE_TESTS_MODULE OFF)
vix_sdk_profile_default(VIX_ENABLE_TEMPLATE ON)
vix_sdk_profile_default(VIX_ENABLE_UI ON)
vix_sdk_profile_default(VIX_UI_ENABLE_LINUX_WEBVIEW OFF)
vix_sdk_profile_default(VIX_CLI_ENABLE_DESKTOP OFF)
vix_sdk_profile_default(VIX_ENABLE_NOTE ON)
vix_sdk_profile_default(VIX_ENABLE_PROCESS ON)
vix_sdk_profile_default(VIX_ENABLE_ENGINE ON)
vix_sdk_profile_default(VIX_ENABLE_THREADPOOL ON)
vix_sdk_profile_default(VIX_ENABLE_KV OFF)
vix_sdk_profile_default(VIX_ENABLE_AGENT OFF)
vix_sdk_profile_default(VIX_ENABLE_GAME OFF)
vix_sdk_profile_default(VIX_GAME_ENABLE_SDL OFF)
vix_sdk_profile_default(VIX_GAME_ENABLE_SDL_OPENGL OFF)
endfunction()
if (NOT _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "legacy")
vix_sdk_profile_common()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "web")
vix_sdk_profile_default(VIX_ENABLE_WEBSOCKET ON)
vix_sdk_profile_default(VIX_ENABLE_MIDDLEWARE ON)
vix_sdk_profile_default(VIX_ENABLE_VALIDATION ON)
vix_sdk_profile_default(VIX_ENABLE_CRYPTO ON)
vix_sdk_profile_default(VIX_ENABLE_WEBRPC ON)
vix_sdk_profile_default(VIX_ENABLE_REQUESTS ON)
vix_sdk_profile_default(VIX_ENABLE_REALTIME ON)
elseif (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "data")
vix_sdk_profile_default(VIX_ENABLE_DB ON)
vix_sdk_profile_default(VIX_ENABLE_ORM ON)
vix_sdk_profile_default(VIX_ENABLE_KV ON)
vix_sdk_profile_default(VIX_ENABLE_CACHE ON)
vix_sdk_profile_default(VIX_DB_USE_SQLITE ON)
elseif (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "desktop")
vix_sdk_profile_default(VIX_CLI_ENABLE_DESKTOP ON)
if (UNIX AND NOT APPLE)
vix_sdk_profile_default(VIX_UI_ENABLE_LINUX_WEBVIEW ON)
endif()
elseif (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "p2p")
vix_sdk_profile_default(VIX_ENABLE_P2P ON)
vix_sdk_profile_default(VIX_ENABLE_P2P_HTTP ON)
vix_sdk_profile_default(VIX_ENABLE_CRYPTO ON)
vix_sdk_profile_default(VIX_ENABLE_CACHE ON)
elseif (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "game")
vix_sdk_profile_default(VIX_ENABLE_GAME ON)
vix_sdk_profile_default(VIX_GAME_ENABLE_SDL ON)
vix_sdk_profile_default(VIX_GAME_ENABLE_SDL_OPENGL ON)
elseif (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "agent")
vix_sdk_profile_default(VIX_ENABLE_AGENT ON)
vix_sdk_profile_default(VIX_ENABLE_CACHE ON)
elseif (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all")
vix_sdk_profile_default(VIX_ENABLE_ORM ON)
vix_sdk_profile_default(VIX_ENABLE_WEBSOCKET ON)
vix_sdk_profile_default(VIX_ENABLE_MIDDLEWARE ON)
vix_sdk_profile_default(VIX_ENABLE_DB ON)
vix_sdk_profile_default(VIX_DB_USE_MYSQL ON)
vix_sdk_profile_default(VIX_ENABLE_P2P ON)
vix_sdk_profile_default(VIX_ENABLE_P2P_HTTP ON)
vix_sdk_profile_default(VIX_ENABLE_CACHE ON)
vix_sdk_profile_default(VIX_ENABLE_VALIDATION ON)
vix_sdk_profile_default(VIX_ENABLE_CRYPTO ON)
vix_sdk_profile_default(VIX_ENABLE_WEBRPC ON)
vix_sdk_profile_default(VIX_ENABLE_REQUESTS ON)
vix_sdk_profile_default(VIX_ENABLE_REALTIME ON)
vix_sdk_profile_default(VIX_ENABLE_KV ON)
vix_sdk_profile_default(VIX_ENABLE_AGENT ON)
vix_sdk_profile_default(VIX_ENABLE_GAME ON)
vix_sdk_profile_default(VIX_CLI_ENABLE_DESKTOP ON)
if (UNIX AND NOT APPLE)
vix_sdk_profile_default(VIX_UI_ENABLE_LINUX_WEBVIEW ON)
endif()
vix_sdk_profile_default(VIX_GAME_ENABLE_SDL ON)
vix_sdk_profile_default(VIX_GAME_ENABLE_SDL_OPENGL ON)
endif()
if (VIX_ENABLE_CLI)
vix_sdk_profile_default(VIX_ENABLE_CRYPTO ON)
vix_sdk_profile_default(VIX_ENABLE_CACHE ON)
vix_sdk_profile_default(VIX_ENABLE_P2P ON)
vix_sdk_profile_default(VIX_ENABLE_AGENT ON)
vix_sdk_profile_default(VIX_ENABLE_REQUESTS ON)
endif()
endif()
function(vix_sdk_profile_user_set out_var option_name)
list(FIND _VIX_SDK_PROFILE_USER_CACHE_VARS "${option_name}" _vix_sdk_profile_user_index)
if (_vix_sdk_profile_user_index EQUAL -1)
set(${out_var} OFF PARENT_SCOPE)
else()
set(${out_var} ON PARENT_SCOPE)
endif()
endfunction()
set(_VIX_SDK_PACKAGE_DB ON)
set(_VIX_SDK_PACKAGE_ORM ON)
set(_VIX_SDK_PACKAGE_WEBSOCKET ON)
set(_VIX_SDK_PACKAGE_P2P ON)
set(_VIX_SDK_PACKAGE_P2P_HTTP ON)
set(_VIX_SDK_PACKAGE_AGENT ON)
set(_VIX_SDK_PACKAGE_GAME ON)
set(_VIX_SDK_PACKAGE_REALTIME ON)
if (NOT _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "legacy")
vix_sdk_profile_user_set(_VIX_SDK_USER_DB VIX_ENABLE_DB)
vix_sdk_profile_user_set(_VIX_SDK_USER_ORM VIX_ENABLE_ORM)
vix_sdk_profile_user_set(_VIX_SDK_USER_WEBSOCKET VIX_ENABLE_WEBSOCKET)
vix_sdk_profile_user_set(_VIX_SDK_USER_P2P VIX_ENABLE_P2P)
vix_sdk_profile_user_set(_VIX_SDK_USER_P2P_HTTP VIX_ENABLE_P2P_HTTP)
vix_sdk_profile_user_set(_VIX_SDK_USER_AGENT VIX_ENABLE_AGENT)
vix_sdk_profile_user_set(_VIX_SDK_USER_GAME VIX_ENABLE_GAME)
vix_sdk_profile_user_set(_VIX_SDK_USER_REALTIME VIX_ENABLE_REALTIME)
set(_VIX_SDK_PACKAGE_DB OFF)
set(_VIX_SDK_PACKAGE_ORM OFF)
set(_VIX_SDK_PACKAGE_WEBSOCKET OFF)
set(_VIX_SDK_PACKAGE_P2P OFF)
set(_VIX_SDK_PACKAGE_P2P_HTTP OFF)
set(_VIX_SDK_PACKAGE_AGENT OFF)
set(_VIX_SDK_PACKAGE_GAME OFF)
set(_VIX_SDK_PACKAGE_REALTIME OFF)
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "data" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_DB AND VIX_ENABLE_DB))
set(_VIX_SDK_PACKAGE_DB ON)
endif()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "data" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_ORM AND VIX_ENABLE_ORM))
set(_VIX_SDK_PACKAGE_ORM ON)
endif()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "web" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_WEBSOCKET AND VIX_ENABLE_WEBSOCKET))
set(_VIX_SDK_PACKAGE_WEBSOCKET ON)
endif()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "p2p" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_P2P AND VIX_ENABLE_P2P))
set(_VIX_SDK_PACKAGE_P2P ON)
endif()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "p2p" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_P2P_HTTP AND VIX_ENABLE_P2P_HTTP))
set(_VIX_SDK_PACKAGE_P2P_HTTP ON)
endif()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "agent" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_AGENT AND VIX_ENABLE_AGENT))
set(_VIX_SDK_PACKAGE_AGENT ON)
endif()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "game" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_GAME AND VIX_ENABLE_GAME))
set(_VIX_SDK_PACKAGE_GAME ON)
endif()
if (_VIX_SDK_PROFILE_EFFECTIVE STREQUAL "web" OR _VIX_SDK_PROFILE_EFFECTIVE STREQUAL "all" OR (_VIX_SDK_USER_REALTIME AND VIX_ENABLE_REALTIME))
set(_VIX_SDK_PACKAGE_REALTIME ON)
endif()
endif()
# ----------------------------------------------------
# Module test defaults
# ----------------------------------------------------
# The root tests/ directory may be empty. In umbrella builds, tests live
# inside modules/*, so VIX_BUILD_TESTS must propagate to module options.
set(VIX_ERROR_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::error tests")
set(VIX_PATH_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::path tests")
set(VIX_FS_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::fs tests")
set(VIX_IO_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::io tests")
set(VIX_ENV_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::env tests")
set(VIX_OS_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::os tests")
set(VIX_LOG_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::log tests")
set(VIX_UTILS_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::utils tests")
set(VIX_JSON_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::json tests")
set(VIX_CORE_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::core tests")
set(VIX_ASYNC_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::async tests")
set(VIX_CRYPTO_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::crypto tests")
set(VIX_CONVERSION_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::conversion tests")
set(VIX_VALIDATION_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::validation tests")
set(VIX_WEBRPC_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::webrpc tests")
set(VIX_REQUESTS_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::requests tests")
set(VIX_REALTIME_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::realtime tests")
set(VIX_NET_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::net tests")
set(VIX_SYNC_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::sync tests")
set(VIX_CACHE_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::cache tests")
set(VIX_P2P_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::p2p tests")
set(VIX_P2P_HTTP_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::p2p_http tests")
set(VIX_DB_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::db tests")
set(VIX_MIDDLEWARE_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::middleware tests")
set(VIX_CLI_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::cli tests")
set(VIX_CLI_ENABLE_DESKTOP ${VIX_CLI_ENABLE_DESKTOP} CACHE BOOL "Build vix desktop CLI support through vix::ui")
set(VIX_WEBSOCKET_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::websocket tests")
set(VIX_UI_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::ui tests")
set(VIX_NOTE_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::note tests")
set(VIX_ENGINE_BUILD_TESTS ${VIX_BUILD_TESTS} CACHE BOOL "Build vix::engine tests")
# Some modules use their own public option names.
set(TEMPLATE_BUILD_TESTS ${VIX_TEMPLATE_BUILD_TESTS} CACHE BOOL "Build template tests")
set(UI_BUILD_TESTS ${VIX_UI_BUILD_TESTS} CACHE BOOL "Build ui tests")
set(UI_BUILD_EXAMPLES ${VIX_UI_BUILD_EXAMPLES} CACHE BOOL "Build ui examples")
set(UI_BUILD_BENCHMARKS ${VIX_UI_BUILD_BENCHMARKS} CACHE BOOL "Build ui benchmarks")
set(VIX_AI_AGENT_BUILD_TESTS ${VIX_AGENT_BUILD_TESTS} CACHE BOOL "Build vix ai agent tests")
set(VIX_UI_ENABLE_LINUX_WEBVIEW ${VIX_UI_ENABLE_LINUX_WEBVIEW}
CACHE BOOL "Enable Linux desktop WebView backend for vix::ui")
# ----------------------------------------------------
# Testing bootstrap
# ----------------------------------------------------
# Must happen before add_subdirectory(modules/*), otherwise module tests may
# be built but not registered correctly in the umbrella CTest tree.
if (VIX_BUILD_TESTS)
include(CTest)
enable_testing()
find_package(GTest QUIET)
if (NOT GTest_FOUND)
message(STATUS "GTest not found, fetching googletest...")
fetchcontent_declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
fetchcontent_makeavailable(googletest)
endif()
endif()
# ----------------------------------------------------
# Tooling / Static analysis
# ----------------------------------------------------
if (VIX_ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
if (CLANG_TIDY_EXE)
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
message(STATUS "clang-tidy enabled: ${CLANG_TIDY_EXE}")
else()
message(WARNING "clang-tidy requested but not found")
endif()
endif()
if (VIX_ENABLE_CPPCHECK)
find_program(CPPCHECK_EXE NAMES cppcheck)
if (CPPCHECK_EXE)
set(CMAKE_CXX_CPPCHECK
${CPPCHECK_EXE}
--enable=warning,style,performance,portability
--std=c++20 --inline-suppr
--suppress=unusedFunction
)
message(STATUS "cppcheck enabled: ${CPPCHECK_EXE}")
else()
message(WARNING "cppcheck requested but not found")
endif()
endif()
# ----------------------------------------------------
# Warnings (opt-in reusable interface target)
# ----------------------------------------------------
if (VIX_ENABLE_WARNINGS)
add_library(vix_warnings INTERFACE)
if (MSVC)
target_compile_options(vix_warnings INTERFACE /W4 /permissive-)
else()
target_compile_options(vix_warnings INTERFACE
-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion
)
# Silence some false positives on GCC 13+ (fmt/spdlog inlines)
target_compile_options(vix_warnings INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-Wno-array-bounds>
)
endif()
endif()
# ----------------------------------------------------
# Coverage (Debug only)
# ----------------------------------------------------
if (VIX_ENABLE_COVERAGE AND CMAKE_BUILD_TYPE MATCHES "Debug")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_library(vix_coverage INTERFACE)
target_compile_options(vix_coverage INTERFACE --coverage -O0 -g)
target_link_options(vix_coverage INTERFACE --coverage)
message(STATUS "Coverage flags enabled")
else()
message(WARNING "Coverage only supported on GCC/Clang")
endif()
endif()
# ----------------------------------------------------
# Sanitizers (opt-in, GCC/Clang) — internal flags only
# ----------------------------------------------------
if (VIX_ENABLE_SANITIZERS)
message(STATUS "Sanitizers enabled via internal target flags.")
endif()
# ----------------------------------------------------
# LTO (Release only)
# ----------------------------------------------------
if (VIX_ENABLE_LTO AND CMAKE_BUILD_TYPE MATCHES "Release")
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_ok OUTPUT ipo_err)
if (ipo_ok)
message(STATUS "IPO/LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
else()
message(WARNING "IPO/LTO not supported: ${ipo_err}")
endif()
endif()
# ----------------------------------------------------
# MSVC static runtime (/MT)
# ----------------------------------------------------
if (MSVC AND VIX_MSVC_STATIC_RUNTIME)
foreach(flag_var
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_DEBUG
)
if (DEFINED ${flag_var})
string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()
# ----------------------------------------------------
# Umbrella INTERFACE target (created early)
# ----------------------------------------------------
add_library(vix INTERFACE)
if (WIN32)
target_compile_definitions(vix INTERFACE _WIN32_WINNT=0x0A00 WIN32_LEAN_AND_MEAN NOMINMAX)
endif()
# ----------------------------------------------------
# Third-party: Asio (standalone, header-only)
# Exposes: vix::thirdparty_asio
# ----------------------------------------------------
add_library(vix_thirdparty_asio INTERFACE)
add_library(vix::thirdparty_asio ALIAS vix_thirdparty_asio)
target_compile_definitions(vix_thirdparty_asio INTERFACE ASIO_STANDALONE=1)
if (WIN32)
target_compile_definitions(vix_thirdparty_asio INTERFACE
_WIN32_WINNT=0x0A00
WIN32_LEAN_AND_MEAN
NOMINMAX
)
endif()
set(VIX_THIRDPARTY_ASIO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/asio-src/asio/include")
# Prefer vendored Asio (submodule)
if (EXISTS "${VIX_THIRDPARTY_ASIO_DIR}/asio.hpp")
message(STATUS "Asio: using vendored Asio at ${VIX_THIRDPARTY_ASIO_DIR}")
target_include_directories(vix_thirdparty_asio SYSTEM INTERFACE
$<BUILD_INTERFACE:${VIX_THIRDPARTY_ASIO_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/vix/third_party/asio>
)
else()
message(STATUS "Asio submodule missing, fetching Asio automatically...")
include(FetchContent)
fetchcontent_declare(
asio
GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git
GIT_TAG asio-1-30-2
)
fetchcontent_makeavailable(asio)
target_include_directories(vix_thirdparty_asio SYSTEM INTERFACE
$<BUILD_INTERFACE:${asio_SOURCE_DIR}/asio/include>
)
endif()
target_compile_options(vix_thirdparty_asio INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-Wno-null-dereference>
)
target_link_libraries(vix INTERFACE vix::thirdparty_asio)
add_library(vix::vix ALIAS vix)
# ----------------------------------------------------
# Optional deps: HTTP compression (zlib + brotli)
# Propagate defs/libs to all consumers through vix::vix
# ----------------------------------------------------
if (VIX_ENABLE_HTTP_COMPRESSION)
# ---- zlib (gzip) ----
find_package(ZLIB QUIET)
if (ZLIB_FOUND)
message(STATUS "Compression: zlib found -> gzip enabled")
target_compile_definitions(vix INTERFACE VIX_HAS_ZLIB=1)
if (TARGET ZLIB::ZLIB)
target_link_libraries(vix INTERFACE ZLIB::ZLIB)
else()
add_library(ZLIB::ZLIB INTERFACE IMPORTED)
target_include_directories(ZLIB::ZLIB INTERFACE "${ZLIB_INCLUDE_DIRS}")
target_link_libraries(ZLIB::ZLIB INTERFACE "${ZLIB_LIBRARIES}")
target_link_libraries(vix INTERFACE ZLIB::ZLIB)
endif()
else()
message(STATUS "Compression: zlib not found -> gzip disabled")
endif()
# ---- brotli (br) ----
find_library(BROTLI_ENC NAMES brotlienc)
find_library(BROTLI_COMMON NAMES brotlicommon)
if (BROTLI_ENC AND BROTLI_COMMON)
message(STATUS "Compression: brotli found -> br enabled")
target_compile_definitions(vix INTERFACE VIX_HAS_BROTLI=1)
target_link_libraries(vix INTERFACE ${BROTLI_ENC} ${BROTLI_COMMON})
else()
message(STATUS "Compression: brotli not found -> br disabled")
endif()
endif()
# Attach warnings/coverage only for local builds.
# Do not export them through the installed package.
if (TARGET vix_warnings)
target_link_libraries(vix INTERFACE
$<BUILD_INTERFACE:vix_warnings>
)
endif()
if (TARGET vix_coverage)
target_link_libraries(vix INTERFACE
$<BUILD_INTERFACE:vix_coverage>
)
endif()
# Install include interface root
target_include_directories(vix INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# ----------------------------------------------------
# Add submodules
# ----------------------------------------------------
set(_VIX_JSON_BACKEND "none")
set(JSON_TARGET "")
# --- Error ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/error/CMakeLists.txt")
message(STATUS "Adding 'modules/error'...")
add_subdirectory(modules/error error_build)
else()
message(FATAL_ERROR "Missing 'modules/error'. Run: git submodule update --init --recursive")
endif()
# --- Path ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/path/CMakeLists.txt")
message(STATUS "Adding 'modules/path'...")
add_subdirectory(modules/path path_build)
else()
message(FATAL_ERROR "Missing 'modules/path'. Run: git submodule update --init --recursive")
endif()
# --- FS ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/fs/CMakeLists.txt")
message(STATUS "Adding 'modules/fs'...")
add_subdirectory(modules/fs fs_build)
else()
message(FATAL_ERROR "Missing 'modules/fs'. Run: git submodule update --init --recursive")
endif()
# --- Utils ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/utils/CMakeLists.txt")
message(STATUS "Adding 'modules/utils'...")
add_subdirectory(modules/utils utils_build)
else()
message(FATAL_ERROR "Missing 'modules/utils'. Run: git submodule update --init --recursive")
endif()
# --- Log ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/log/CMakeLists.txt")
message(STATUS "Adding 'modules/log'...")
add_subdirectory(modules/log log_build)
else()
message(FATAL_ERROR "Missing 'modules/log'. Run: git submodule update --init --recursive")
endif()
# --- IO ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/io/CMakeLists.txt")
message(STATUS "Adding 'modules/io'...")
add_subdirectory(modules/io io_build)
else()
message(FATAL_ERROR "Missing 'modules/io'. Run: git submodule update --init --recursive")
endif()
# --- Env ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/env/CMakeLists.txt")
message(STATUS "Adding 'modules/env'...")
add_subdirectory(modules/env env_build)
else()
message(FATAL_ERROR "Missing 'modules/env'. Run: git submodule update --init --recursive")
endif()
# --- OS ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/os/CMakeLists.txt")
message(STATUS "Adding 'modules/os'...")
add_subdirectory(modules/os os_build)
else()
message(FATAL_ERROR "Missing 'modules/os'. Run: git submodule update --init --recursive")
endif()
# --- JSON ---
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/json/CMakeLists.txt")
message(STATUS "Adding 'modules/json'...")
add_subdirectory(modules/json json_build)
set(_VIX_JSON_BACKEND "submodule")
elseif (VIX_FORCE_FETCH_JSON)
message(WARNING "modules/json missing — fetching nlohmann/json fallback")
fetchcontent_declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
fetchcontent_makeavailable(nlohmann_json)
add_library(vix_json INTERFACE)
target_link_libraries(vix_json INTERFACE nlohmann_json::nlohmann_json)
if (NOT TARGET vix::json)
add_library(vix::json ALIAS vix_json)
endif()
set(_VIX_JSON_BACKEND "nlohmann_json")
else()
message(FATAL_ERROR "Missing 'modules/json'. Run: git submodule update --init --recursive")
endif()
# Resolve JSON target name
if (TARGET vix::json)
set(JSON_TARGET vix::json)
elseif (TARGET vix_json)
set(JSON_TARGET vix_json)
else()
message(FATAL_ERROR "JSON backend target not found (expected vix::json or vix_json).")
endif()
# --- WebRPC (optional) ---
set(VIX_HAS_WEBRPC OFF)
if (VIX_ENABLE_WEBRPC AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/webrpc/CMakeLists.txt")
message(STATUS "Adding 'modules/webrpc'...")
add_subdirectory(modules/webrpc webrpc_build)
# Normalise: expose vix::webrpc
if (TARGET vix::webrpc OR TARGET vix_webrpc)
set(VIX_HAS_WEBRPC ON)
if (TARGET vix_webrpc AND NOT TARGET vix::webrpc)
add_library(vix::webrpc ALIAS vix_webrpc)
endif()
else()
message(WARNING "WebRPC module added but no vix::webrpc target was exported.")
endif()
else()
message(STATUS "WebRPC: disabled or not present.")
endif()
# --- Requests (optional, async transport) ---
set(VIX_HAS_REQUESTS OFF)
if (VIX_ENABLE_REQUESTS AND NOT VIX_ENABLE_ASYNC)
message(FATAL_ERROR "Requests requires vix::async. Enable VIX_ENABLE_ASYNC or disable VIX_ENABLE_REQUESTS.")
endif()
if (VIX_ENABLE_REQUESTS AND VIX_ENABLE_ASYNC AND NOT TARGET vix::async AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/async/CMakeLists.txt")
message(STATUS "Adding 'modules/async' for requests...")
add_subdirectory(modules/async async_build)
if (TARGET vix::async OR TARGET vix_async)
set(VIX_HAS_ASYNC ON)
if (TARGET vix_async AND NOT TARGET vix::async)
add_library(vix::async ALIAS vix_async)
endif()
else()
message(FATAL_ERROR "Requests requires vix::async, but the async module did not export it.")
endif()
endif()
if (VIX_ENABLE_REQUESTS AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/requests/CMakeLists.txt")
message(STATUS "Adding 'modules/requests'...")
set(VIX_REQUESTS_BUILD_TESTS ${VIX_REQUESTS_BUILD_TESTS} CACHE BOOL "Build vix::requests tests" FORCE)
set(VIX_REQUESTS_BUILD_EXAMPLES ${VIX_REQUESTS_BUILD_EXAMPLES} CACHE BOOL "Build vix::requests examples" FORCE)
set(VIX_REQUESTS_INSTALL OFF CACHE BOOL "Enable standalone install/package rules" FORCE)
add_subdirectory(modules/requests requests_build)
if (TARGET vix::requests OR TARGET vix_requests)
set(VIX_HAS_REQUESTS ON)
if (TARGET vix_requests AND NOT TARGET vix::requests)
add_library(vix::requests ALIAS vix_requests)
endif()
else()
message(WARNING "Requests module added but no vix::requests target was exported.")
endif()
else()
message(STATUS "Requests: disabled or not present.")
endif()
# --- Tests (optional) ---
set(VIX_HAS_TESTS OFF)
if (VIX_ENABLE_TESTS_MODULE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/tests/CMakeLists.txt")
message(STATUS "Adding 'modules/tests'...")
add_subdirectory(modules/tests tests_build)
if (TARGET vix::tests OR TARGET vix_tests)
set(VIX_HAS_TESTS ON)
if (TARGET vix_tests AND NOT TARGET vix::tests)
add_library(vix::tests ALIAS vix_tests)
endif()
else()
message(WARNING "Tests module added but no vix::tests target was exported.")
endif()
else()
message(STATUS "Tests module: disabled or not present.")
endif()
# --- Time (foundation module) ---
set(VIX_HAS_TIME OFF)
if (VIX_ENABLE_TIME AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/time/CMakeLists.txt")
message(STATUS "Adding 'modules/time'...")
set(VIX_TIME_BUILD_TESTS ${VIX_TIME_BUILD_TESTS} CACHE BOOL "" FORCE)
set(VIX_TIME_BUILD_BENCH ${VIX_TIME_BUILD_BENCH} CACHE BOOL "" FORCE)
add_subdirectory(modules/time time_build)
if (TARGET vix::time OR TARGET vix_time)
set(VIX_HAS_TIME ON)
if (TARGET vix_time AND NOT TARGET vix::time)
add_library(vix::time ALIAS vix_time)
endif()
else()
message(WARNING "Time module added but no vix::time target was exported.")
endif()
else()
message(STATUS "Time: disabled or not present.")
endif()
# --- Crypto (optional) ---
set(VIX_HAS_CRYPTO OFF)
if (VIX_ENABLE_CRYPTO AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/crypto/CMakeLists.txt")
message(STATUS "Adding 'modules/crypto'...")
# Important: en umbrella, crypto ne fait pas find_package(OpenSSL),