forked from thun-res/vlink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
710 lines (677 loc) · 24.5 KB
/
Copy pathCMakeLists.txt
File metadata and controls
710 lines (677 loc) · 24.5 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
#
# Copyright (C) 2026 by Thun Lu. All rights reserved.
#
cmake_minimum_required(VERSION 3.15...3.31)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# version
file(STRINGS version.txt VLINK_VERSION)
string(TIMESTAMP VLINK_VERSION_TIMESTAMP "%Y-%m-%d %H:%M:%S")
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VLINK_VERSION_COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
execute_process(
COMMAND git describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VLINK_VERSION_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
# project
project(
vlink
VERSION ${VLINK_VERSION}
DESCRIPTION "A high-performance communication middleware"
LANGUAGES CXX
)
set(DOC_PROJECT_NAME "VLink")
set(DOC_PROJECT_LOGO "./doc/images/vlink-icon.svg")
set(PROJECT_NAMESPACE "vlink::")
# common
include(cmake/functions/common.cmake)
include(cmake/functions/generator.cmake)
vlink_check()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME runtime)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
foreach(OUTPUTCONFIG Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${OUTPUTCONFIG}" OUTPUTCONFIG_U)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG_U} ${CMAKE_BINARY_DIR}/output/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG_U} ${CMAKE_BINARY_DIR}/output/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG_U} ${CMAKE_BINARY_DIR}/output/lib)
endforeach()
# set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Debug;Release;MinSizeRel" CACHE STRING "" FORCE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# compiler-optimize
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO")
add_compile_options(/wd4068 /wd4158 /wd4819 /wd5287)
add_compile_options(/GL)
add_link_options(/LTCG)
add_link_options(/IGNORE:4078)
endif()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++20" COMPILER_SUPPORTS_CXX20)
# ipo
if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
if(NOT MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported)
if(ipo_supported)
message(STATUS "Enable Interprocedural Optimization")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
endif()
endif()
# options
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ENABLE_CPM "Enable cpm build" OFF)
option(ENABLE_CPM_ALL "Enable cpm-all build" OFF)
option(ENABLE_CCACHE_BUILD "Enable ccache build" OFF)
option(ENABLE_DOC "Enable doc" OFF)
option(ENABLE_CXX_STD_20 "Enable cxx standard 20 features" ${COMPILER_SUPPORTS_CXX20})
option(ENABLE_C_API "Enable c api" ON)
option(ENABLE_PYTHON_API "Enable python api" OFF)
option(ENABLE_SECURITY "Enable security(ssl)" ON)
option(ENABLE_SQLITE "Enable sqlite" ON)
option(ENABLE_ZSTD "Enable zstd" ON)
option(ENABLE_CLI_INFO "Enable cli-info" ON)
option(ENABLE_CLI_BAG "Enable cli-bag" ON)
option(ENABLE_CLI_EPROTO "Enable cli-eproto" ON)
option(ENABLE_CLI_EFBS "Enable cli-efbs" ON)
option(ENABLE_CLI_LIST "Enable cli-list" ON)
option(ENABLE_CLI_MONITOR "Enable cli-monitor" ON)
option(ENABLE_CLI_DUMP "Enable cli-dump" ON)
option(ENABLE_CLI_CHECK "Enable cli-check" ON)
option(ENABLE_CLI_BENCH "Enable cli-bench" ON)
option(ENABLE_CLI_TRIGGER "Enable cli-trigger" ON)
option(ENABLE_PROXY "Enable proxy" ON)
option(ENABLE_VIEWER "Enable viewer" OFF)
option(ENABLE_WEBVIZ "Enable webviz" OFF)
option(ENABLE_EXPRTK "Enable exprtk expression engine (required by cli-dump/viewer/webviz)" ON)
option(ENABLE_SYMLINKS "Install symlink" ON)
option(ENABLE_COMPLETIONS "Install shell completion scripts" ON)
if(CMAKE_EXPORT_COMPILE_COMMANDS OR CMAKE_CXX_CLANG_TIDY)
option(ENABLE_EXAMPLES "Enable examples" ON)
else()
option(ENABLE_EXAMPLES "Enable examples" OFF)
endif()
option(ENABLE_EXAMPLES_ALL "Enable examples-all" OFF)
option(ENABLE_TEST "Enable test" OFF)
option(ENABLE_TEST_WARN "Enable test compiler warnings" OFF)
option(ENABLE_TEST_SANITIZE "Enable test memory sanitize" OFF)
option(ENABLE_TEST_COVERAGE "Enable test code coverage" OFF)
if(ENABLE_CXX_STD_20)
set(CMAKE_CXX_STANDARD 20)
endif()
if(ANDROID OR QNX)
set(SELECT_LOG_BACKEND
"native"
CACHE STRING "Log backend [spdlog|quill|dlt|native]"
)
else()
set(SELECT_LOG_BACKEND
"spdlog"
CACHE STRING "Log backend [spdlog|quill|dlt|native]"
)
endif()
set(INSTALL_CONFIG_DIR
${CMAKE_INSTALL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}
CACHE STRING "Install dir for config files (relative to prefix)"
)
set_property(CACHE SELECT_LOG_BACKEND PROPERTY STRINGS spdlog quill dlt native)
if("${SELECT_LOG_BACKEND}" STREQUAL "spdlog")
set(ENABLE_LOG_SPD ON)
set(ENABLE_LOG_QUI OFF)
set(ENABLE_LOG_DLT OFF)
set(ENABLE_LOG_NAT OFF)
elseif("${SELECT_LOG_BACKEND}" STREQUAL "quill")
set(ENABLE_LOG_SPD OFF)
set(ENABLE_LOG_QUI ON)
set(ENABLE_LOG_DLT OFF)
set(ENABLE_LOG_NAT OFF)
elseif("${SELECT_LOG_BACKEND}" STREQUAL "dlt")
set(ENABLE_LOG_SPD OFF)
set(ENABLE_LOG_QUI OFF)
set(ENABLE_LOG_DLT ON)
set(ENABLE_LOG_NAT OFF)
elseif("${SELECT_LOG_BACKEND}" STREQUAL "native")
set(ENABLE_LOG_SPD OFF)
set(ENABLE_LOG_QUI OFF)
set(ENABLE_LOG_DLT OFF)
set(ENABLE_LOG_NAT ON)
else()
set(ENABLE_LOG_SPD ON)
set(ENABLE_LOG_QUI OFF)
set(ENABLE_LOG_DLT OFF)
set(ENABLE_LOG_NAT OFF)
endif()
if(IS_ABSOLUTE "${INSTALL_CONFIG_DIR}")
string(REGEX REPLACE "^([A-Za-z]:)?[\\/]+" "" BUILD_CONFIG_DIR "${INSTALL_CONFIG_DIR}")
else()
set(BUILD_CONFIG_DIR ${INSTALL_CONFIG_DIR})
endif()
# cpm-cmake
if(ENABLE_CPM OR ENABLE_CPM_ALL)
include(cmake/cpm_thirdparty.cmake)
endif()
# requires
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
find_package(Threads REQUIRED)
if(ENABLE_SECURITY)
find_package(OpenSSL QUIET)
if(NOT TARGET OpenSSL::Crypto)
message(WARNING "Can not find openssl, set ENABLE_SECURITY to OFF")
set(ENABLE_SECURITY OFF)
endif()
endif()
if(ENABLE_SQLITE)
find_package(SQLite3 QUIET)
if(NOT TARGET SQLite3::SQLite3 AND NOT TARGET SQLite::SQLite3)
message(WARNING "Can not find sqlite, set ENABLE_SQLITE to OFF")
set(ENABLE_SQLITE OFF)
endif()
endif()
if(ENABLE_ZSTD)
find_package(zstd CONFIG QUIET)
if(NOT zstd_FOUND)
find_package(zstd MODULE QUIET)
endif()
if(NOT TARGET zstd::libzstd_shared AND NOT TARGET zstd::libzstd_static)
message(WARNING "Can not find zstd, set ENABLE_ZSTD to OFF")
set(ENABLE_ZSTD OFF)
endif()
endif()
if(ENABLE_CLI_EPROTO
OR ENABLE_CLI_DUMP
OR ENABLE_VIEWER
OR ENABLE_WEBVIZ
)
find_package(Protobuf CONFIG QUIET)
if(NOT TARGET protobuf::libprotobuf)
find_package(Protobuf QUIET)
endif()
if(NOT TARGET protobuf::libprotobuf)
message(WARNING "Can not find protobuf, set ENABLE_CLI_EPROTO/ENABLE_CLI_DUMP/ENABLE_VIEWER/ENABLE_WEBVIZ to OFF")
set(ENABLE_CLI_EPROTO OFF)
set(ENABLE_CLI_DUMP OFF)
set(ENABLE_VIEWER OFF)
set(ENABLE_WEBVIZ OFF)
endif()
endif()
if(ENABLE_PROXY)
if(NOT SKIP_DDS)
find_package(fastdds CONFIG QUIET)
find_package(fastrtps CONFIG QUIET)
endif()
if(NOT SKIP_DDSC)
find_package(CycloneDDS CONFIG QUIET)
endif()
if(NOT TARGET fastrtps
AND NOT TARGET fastdds
AND NOT TARGET CycloneDDS::ddsc
)
message(WARNING "Can not find fastdds or cyclonedds, set ENABLE_PROXY to OFF")
set(ENABLE_PROXY OFF)
endif()
endif()
if(ENABLE_CLI_EFBS
OR ENABLE_CLI_DUMP
OR ENABLE_VIEWER
OR ENABLE_WEBVIZ
)
find_package(flatbuffers CONFIG QUIET)
if((NOT DEFINED flatbuffers_VERSION OR flatbuffers_VERSION STREQUAL "") AND DEFINED flatbuffers_VERSION_STRING)
set(flatbuffers_VERSION ${flatbuffers_VERSION_STRING})
endif()
if((NOT TARGET flatbuffers::flatbuffers_shared AND NOT TARGET flatbuffers::flatbuffers)
OR (NOT DEFINED flatbuffers_VERSION)
OR (flatbuffers_VERSION VERSION_LESS "22.0.0")
)
message(WARNING "Can not find flatbuffers, set ENABLE_CLI_EFBS/ENABLE_CLI_DUMP/ENABLE_VIEWER/ENABLE_WEBVIZ to OFF")
set(ENABLE_CLI_EFBS OFF)
set(ENABLE_CLI_DUMP OFF)
set(ENABLE_VIEWER OFF)
set(ENABLE_WEBVIZ OFF)
endif()
endif()
if(ENABLE_LOG_DLT)
find_package(automotive-dlt QUIET)
if(NOT TARGET Genivi::dlt)
message(WARNING "Can not find dlt, set ENABLE_LOG_DLT to OFF")
set(ENABLE_LOG_DLT OFF)
endif()
endif()
if(ENABLE_VIEWER OR ENABLE_WEBVIZ)
if(NOT ENABLE_PROXY)
message(WARNING "Can not build viewer without proxy, set ENABLE_VIEWER/ENABLE_WEBVIZ to OFF")
set(ENABLE_VIEWER OFF)
endif()
endif()
set(VLINK_ENABLE_CXX_STD_20 ${ENABLE_CXX_STD_20})
set(VLINK_ENABLE_C_API ${ENABLE_C_API})
set(VLINK_ENABLE_SECURITY ${ENABLE_SECURITY})
set(VLINK_ENABLE_SQLITE ${ENABLE_SQLITE})
set(VLINK_ENABLE_ZSTD ${ENABLE_ZSTD})
set(VLINK_ENABLE_CLI_INFO ${ENABLE_CLI_INFO})
set(VLINK_ENABLE_CLI_BAG ${ENABLE_CLI_BAG})
set(VLINK_ENABLE_CLI_BENCH ${ENABLE_CLI_BENCH})
set(VLINK_ENABLE_CLI_EPROTO ${ENABLE_CLI_EPROTO})
set(VLINK_ENABLE_CLI_EFBS ${ENABLE_CLI_EFBS})
set(VLINK_ENABLE_CLI_LIST ${ENABLE_CLI_LIST})
set(VLINK_ENABLE_CLI_MONITOR ${ENABLE_CLI_MONITOR})
set(VLINK_ENABLE_CLI_DUMP ${ENABLE_CLI_DUMP})
set(VLINK_ENABLE_CLI_CHECK ${ENABLE_CLI_CHECK})
set(VLINK_ENABLE_CLI_TRIGGER ${ENABLE_CLI_TRIGGER})
set(VLINK_ENABLE_LOG_SPD ${ENABLE_LOG_SPD})
set(VLINK_ENABLE_LOG_QUI ${ENABLE_LOG_QUI})
set(VLINK_ENABLE_LOG_DLT ${ENABLE_LOG_DLT})
set(VLINK_ENABLE_LOG_NAT ${ENABLE_LOG_NAT})
set(VLINK_ENABLE_EXPRTK ${ENABLE_EXPRTK})
set(VLINK_ENABLE_PROXY ${ENABLE_PROXY})
set(VLINK_ENABLE_VIEWER ${ENABLE_VIEWER})
set(VLINK_ENABLE_WEBVIZ ${ENABLE_WEBVIZ})
set(VLINK_ENABLE_SYMLINKS ${ENABLE_SYMLINKS})
set(VLINK_ENABLE_COMPLETIONS ${ENABLE_COMPLETIONS})
set(VLINK_ENABLE_EXAMPLES ${ENABLE_EXAMPLES})
set(VLINK_ENABLE_EXAMPLES_ALL ${ENABLE_EXAMPLES_ALL})
set(VLINK_ENABLE_TEST ${ENABLE_TEST})
# thirdparty(headeronly)
add_subdirectory(thirdparty/lzav)
add_subdirectory(thirdparty/argparse)
add_subdirectory(thirdparty/bitsery)
add_subdirectory(thirdparty/doctest)
add_subdirectory(thirdparty/json)
add_subdirectory(thirdparty/mcap)
add_subdirectory(thirdparty/eigen3)
add_subdirectory(thirdparty/exprtk)
add_subdirectory(thirdparty/robin-map)
add_subdirectory(thirdparty/asio)
add_subdirectory(thirdparty/spdlog)
add_subdirectory(thirdparty/quill)
add_subdirectory(thirdparty/websocketpp)
# ccache
if(ENABLE_CCACHE_BUILD)
if(WIN32)
set(VLINK_COMPILER_CACHE sccache)
else()
set(VLINK_COMPILER_CACHE ccache)
endif()
find_program(CCACHE_FOUND ${VLINK_COMPILER_CACHE})
if(CCACHE_FOUND)
set(CMAKE_C_COMPILER_LAUNCHER ${VLINK_COMPILER_CACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${VLINK_COMPILER_CACHE})
endif()
endif()
# src
file(GLOB_RECURSE PROJECT_HDRS CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/include/*.h)
file(GLOB_RECURSE PROJECT_SRCS CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/*.cc)
add_library(${PROJECT_NAME} ${PROJECT_HDRS} ${PROJECT_SRCS})
add_library(${PROJECT_NAMESPACE}${PROJECT_NAME} ALIAS ${PROJECT_NAME})
set_target_properties(
${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
if(ENABLE_CXX_STD_20)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
target_compile_options(
${PROJECT_NAME}
PUBLIC
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,10>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,11>>:-fcoroutines>
)
else()
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
endif()
target_include_directories(
${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/${CMAKE_PROJECT_NAME}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(BUILD_SHARED_LIBS)
set(VLINK_APP_DEFINES)
set(VLINK_LIB_DEFINES "VLINK_LIBRARY")
target_compile_definitions(${PROJECT_NAME} PRIVATE ${VLINK_LIB_DEFINES})
else()
set(VLINK_APP_DEFINES "VLINK_LIBRARY_STATIC")
set(VLINK_LIB_DEFINES "VLINK_LIBRARY_STATIC")
target_compile_definitions(${PROJECT_NAME} PUBLIC ${VLINK_LIB_DEFINES})
endif()
if(WIN32)
list(APPEND VLINK_PLATFORM_LIBS Iphlpapi ws2_32)
if(MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4819")
target_compile_options(${PROJECT_NAME} PUBLIC "/utf-8")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-ignored-attributes)
endif()
else()
target_compile_options(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:-fvisibility=hidden>)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND VLINK_PLATFORM_LIBS ${CMAKE_DL_LIBS} rt)
list(APPEND VLINK_PLATFORM_LIBS
"$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:-lstdc++fs>"
)
elseif(QNX)
list(APPEND VLINK_PLATFORM_LIBS slog2 socket)
if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "8.0.0")
list(APPEND VLINK_PLATFORM_LIBS fsnotify)
else()
list(APPEND VLINK_PLATFORM_LIBS c++fs)
endif()
elseif(ANDROID)
list(APPEND VLINK_PLATFORM_LIBS log)
elseif(APPLE)
target_compile_definitions(${PROJECT_NAME} PRIVATE "_DARWIN_C_SOURCE")
endif()
set(PROTOBUF_GCC_POSITIVE_FLAGS)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
list(APPEND PROTOBUF_GCC_POSITIVE_FLAGS -Wno-stringop-overflow)
endif()
if(PROTOBUF_GCC_POSITIVE_FLAGS)
target_compile_options(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROTOBUF_GCC_POSITIVE_FLAGS}>)
target_link_options(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROTOBUF_GCC_POSITIVE_FLAGS}>)
endif()
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads)
target_link_libraries(${PROJECT_NAME} PRIVATE ${VLINK_PLATFORM_LIBS})
target_link_libraries(
${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:thirdparty::lzav> $<BUILD_INTERFACE:thirdparty::mcap>
$<BUILD_INTERFACE:thirdparty::json> $<BUILD_INTERFACE:thirdparty::robin-map>
)
if(ENABLE_SECURITY)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::Crypto)
target_compile_definitions(${PROJECT_NAME} PRIVATE "VLINK_ENABLE_SECURITY")
endif()
if(ENABLE_SQLITE)
if(TARGET SQLite3::SQLite3)
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite3::SQLite3)
elseif(TARGET SQLite::SQLite3)
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite::SQLite3)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE "VLINK_ENABLE_SQLITE")
endif()
if(ENABLE_ZSTD)
if(TARGET zstd::libzstd_shared)
target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_shared)
elseif(TARGET zstd::libzstd_static)
target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_static)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE "VLINK_ENABLE_ZSTD")
endif()
if(ENABLE_LOG_SPD)
target_compile_definitions(${PROJECT_NAME} PRIVATE "VLINK_ENABLE_LOG_SPD")
target_link_libraries(${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:thirdparty::spdlog>)
endif()
if(ENABLE_LOG_QUI)
target_compile_definitions(${PROJECT_NAME} PRIVATE "VLINK_ENABLE_LOG_QUI")
target_link_libraries(${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:thirdparty::quill>)
endif()
if(ENABLE_LOG_DLT)
target_compile_definitions(${PROJECT_NAME} PRIVATE "VLINK_ENABLE_LOG_DLT")
target_link_libraries(${PROJECT_NAME} PRIVATE Genivi::dlt)
endif()
# install
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT runtime
NAMELINK_COMPONENT devel
)
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/include/${CMAKE_PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT devel
PATTERN ".*" EXCLUDE
)
if(EXISTS ${PROJECT_SOURCE_DIR}/CHANGELOG.md)
install(FILES ${PROJECT_SOURCE_DIR}/CHANGELOG.md DESTINATION ${INSTALL_CONFIG_DIR})
endif()
if(ENABLE_DOC)
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/examples
DESTINATION ${INSTALL_CONFIG_DIR}
COMPONENT devel
)
endif()
# uninstall
if(NOT TARGET uninstall)
configure_file("${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" "${CMAKE_BINARY_DIR}/uninstall.cmake" @ONLY)
add_custom_target(
uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/uninstall.cmake
COMMENT "Uninstalling files listed in install_manifest.txt ..."
)
endif()
# modules
add_subdirectory(modules/intra)
add_subdirectory(modules/shm)
add_subdirectory(modules/shm2)
add_subdirectory(modules/zenoh)
add_subdirectory(modules/dds)
add_subdirectory(modules/ddsc)
add_subdirectory(modules/ddsr)
add_subdirectory(modules/ddst)
add_subdirectory(modules/someip)
add_subdirectory(modules/fdbus)
add_subdirectory(modules/qnx)
add_subdirectory(modules/mqtt)
set(VLINK_DEFAULT_LIBRARIES ${VLINK_LIBRARIES})
if(VLINK_LIBRARIES)
set(VLINK_NO_INTRA_LIBRARIES ${VLINK_LIBRARIES})
list(REMOVE_ITEM VLINK_NO_INTRA_LIBRARIES ${PROJECT_NAMESPACE}intra)
endif()
string(REPLACE "${PROJECT_NAMESPACE}" "" VLINK_LIBRARIES_INFO "${VLINK_LIBRARIES}")
string(REPLACE ";" "," VLINK_LIBRARIES_INFO "${VLINK_LIBRARIES_INFO}")
# all
if(NOT TARGET vlink::all)
add_library(vlink::all INTERFACE IMPORTED GLOBAL)
set_target_properties(vlink::all PROPERTIES INTERFACE_LINK_LIBRARIES "vlink::vlink;${VLINK_LIBRARIES}")
endif()
# c-interface
if(ENABLE_C_API)
add_subdirectory(c_api)
endif()
# python-interface
if(ENABLE_PYTHON_API)
add_subdirectory(python_api)
endif()
# exprtk
if(ENABLE_EXPRTK
AND (ENABLE_CLI_DUMP
OR ENABLE_VIEWER
OR ENABLE_WEBVIZ)
)
add_subdirectory(exprtk)
endif()
# cli
if(ENABLE_CLI_INFO)
add_subdirectory(cli/info)
endif()
if(ENABLE_CLI_BAG)
add_subdirectory(cli/bag)
endif()
if(ENABLE_CLI_EPROTO)
add_subdirectory(cli/eproto)
endif()
if(ENABLE_CLI_EFBS)
add_subdirectory(cli/efbs)
endif()
if(ENABLE_CLI_LIST)
add_subdirectory(cli/list)
endif()
if(ENABLE_CLI_MONITOR)
add_subdirectory(cli/monitor)
endif()
if(ENABLE_CLI_DUMP)
add_subdirectory(cli/dump)
endif()
if(ENABLE_CLI_CHECK)
add_subdirectory(cli/check)
endif()
if(ENABLE_CLI_BENCH)
add_subdirectory(cli/bench)
endif()
if(ENABLE_CLI_TRIGGER)
add_subdirectory(cli/trigger)
endif()
# proxy
if(ENABLE_PROXY)
add_subdirectory(proxy)
endif()
# viewer
if(ENABLE_VIEWER)
add_subdirectory(viewer)
endif()
# webviz
if(ENABLE_WEBVIZ)
add_subdirectory(webviz)
endif()
# examples
if(ENABLE_EXAMPLES OR ENABLE_EXAMPLES_ALL)
add_subdirectory(examples)
endif()
# add_subdirectory(tools/test_plugins/plugin_decoder)
# test
if(ENABLE_TEST)
enable_testing()
add_subdirectory(test)
if(ENABLE_TEST_SANITIZE)
vlink_test_sanitize(${PROJECT_NAME})
endif()
if(ENABLE_TEST_COVERAGE)
set(VLINK_TEST_COVERAGE_EXCLUDES
*/build-*/*
*/c_api/*
*/cli/*
*/exprtk/*
*/proxy/*
*/test/*
*/thirdparty/*
*/.vlink-cpm-cache/*
*/modules/dds/builtin/*
*/modules/ddsc/builtin/*
*/modules/ddsr/builtin/*
*/modules/ddst/builtin/*
*/include/private/*
*/src/private/*
)
list(REMOVE_DUPLICATES VLINK_TEST_COVERAGE_EXCLUDES)
vlink_test_coverage(${PROJECT_NAME} TYPE lcov EXCLUDES ${VLINK_TEST_COVERAGE_EXCLUDES})
endif()
endif()
if(ENABLE_TEST_WARN)
vlink_test_warn(${PROJECT_NAME})
endif()
# doc
if(ENABLE_DOC)
add_subdirectory(doc)
endif()
# export
vlink_export(${PROJECT_NAME} ${PROJECT_NAME} ${PROJECT_NAMESPACE} ${CMAKE_PROJECT_VERSION})
# license
include(${CMAKE_SOURCE_DIR}/cmake/install_licenses.cmake)
# script
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/output")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/output/${BUILD_CONFIG_DIR}")
if(ENABLE_WEBVIZ)
if(ENABLE_WEBVIZ_FOXGLOVE AND TARGET vlink-foxglove)
set(VLINK_WEBVIZ_COMPLETION_TARGET "foxglove")
elseif(ENABLE_WEBVIZ_RERUN AND TARGET vlink-rerun)
set(VLINK_WEBVIZ_COMPLETION_TARGET "rerun")
else()
set(VLINK_WEBVIZ_COMPLETION_TARGET "")
endif()
else()
set(VLINK_WEBVIZ_COMPLETION_TARGET "")
endif()
if(WIN32)
configure_file(
"${CMAKE_SOURCE_DIR}/packup/scripts/vlink-setup.bat.in" "${CMAKE_BINARY_DIR}/output/bin/vlink-setup.bat" @ONLY
)
install(FILES ${CMAKE_BINARY_DIR}/output/bin/vlink-setup.bat DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
if(ENABLE_COMPLETIONS)
configure_file(
"${CMAKE_SOURCE_DIR}/packup/scripts/vlink-completions.sh.in"
"${CMAKE_BINARY_DIR}/output/${BUILD_CONFIG_DIR}/vlink-completions.sh" @ONLY
)
install(FILES ${CMAKE_BINARY_DIR}/output/${BUILD_CONFIG_DIR}/vlink-completions.sh DESTINATION ${INSTALL_CONFIG_DIR})
endif()
configure_file(
"${CMAKE_SOURCE_DIR}/packup/scripts/vlink-setup.sh.in" "${CMAKE_BINARY_DIR}/output/vlink-setup.sh" @ONLY
)
install(FILES ${CMAKE_BINARY_DIR}/output/vlink-setup.sh DESTINATION ${INSTALL_CONFIG_DIR})
endif()
# message
set(VLINK_INFO_FILE ${CMAKE_BINARY_DIR}/output/${BUILD_CONFIG_DIR}/vlink-options.txt)
message("")
vlink_log()
vlink_log("┌──────── VLink Options ─────────────────────────────────────────────────────────")
vlink_log("│ Project: ${CMAKE_PROJECT_NAME}")
vlink_log("│ Version: ${VLINK_VERSION}")
vlink_log("│ Time stamp: ${VLINK_VERSION_TIMESTAMP}")
vlink_log("│ Git tag: ${VLINK_VERSION_TAG}")
vlink_log("│ Git commit-id: ${VLINK_VERSION_COMMIT_ID}")
vlink_log("│ Install prefix: ${CMAKE_INSTALL_PREFIX}")
vlink_log("│ Compiler: ${CMAKE_CXX_COMPILER}")
vlink_log("│ Modules: ${VLINK_LIBRARIES_INFO}")
vlink_log("│ CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
vlink_log("│ BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
vlink_log("│ INSTALL_CONFIG_DIR: ${INSTALL_CONFIG_DIR}")
vlink_log("│ ENABLE_CPM: ${ENABLE_CPM}")
vlink_log("│ ENABLE_CPM_ALL: ${ENABLE_CPM_ALL}")
vlink_log("│ ENABLE_CCACHE_BUILD: ${ENABLE_CCACHE_BUILD}")
vlink_log("│ ENABLE_DOC: ${ENABLE_DOC}")
vlink_log("│ ENABLE_CXX_STD_20: ${ENABLE_CXX_STD_20}")
vlink_log("│ ENABLE_C_API: ${ENABLE_C_API}")
vlink_log("│ ENABLE_PYTHON_API: ${ENABLE_PYTHON_API}")
vlink_log("│ ENABLE_SECURITY: ${ENABLE_SECURITY}")
vlink_log("│ ENABLE_SQLITE: ${ENABLE_SQLITE}")
vlink_log("│ ENABLE_ZSTD: ${ENABLE_ZSTD}")
vlink_log("│ ENABLE_CLI_INFO: ${ENABLE_CLI_INFO}")
vlink_log("│ ENABLE_CLI_BAG: ${ENABLE_CLI_BAG}")
vlink_log("│ ENABLE_CLI_EPROTO: ${ENABLE_CLI_EPROTO}")
vlink_log("│ ENABLE_CLI_EFBS: ${ENABLE_CLI_EFBS}")
vlink_log("│ ENABLE_CLI_LIST: ${ENABLE_CLI_LIST}")
vlink_log("│ ENABLE_CLI_MONITOR: ${ENABLE_CLI_MONITOR}")
vlink_log("│ ENABLE_CLI_DUMP: ${ENABLE_CLI_DUMP}")
vlink_log("│ ENABLE_CLI_CHECK: ${ENABLE_CLI_CHECK}")
vlink_log("│ ENABLE_CLI_BENCH: ${ENABLE_CLI_BENCH}")
vlink_log("│ ENABLE_CLI_TRIGGER: ${ENABLE_CLI_TRIGGER}")
vlink_log("│ ENABLE_EXPRTK: ${ENABLE_EXPRTK}")
vlink_log("│ ENABLE_PROXY: ${ENABLE_PROXY}")
vlink_log("│ ENABLE_VIEWER: ${ENABLE_VIEWER}")
vlink_log("│ ENABLE_WEBVIZ: ${ENABLE_WEBVIZ}")
vlink_log("│ ENABLE_SYMLINKS: ${ENABLE_SYMLINKS}")
vlink_log("│ ENABLE_COMPLETIONS: ${ENABLE_COMPLETIONS}")
vlink_log("│ ENABLE_EXAMPLES: ${ENABLE_EXAMPLES}")
vlink_log("│ ENABLE_EXAMPLES_ALL: ${ENABLE_EXAMPLES_ALL}")
vlink_log("│ ENABLE_TEST: ${ENABLE_TEST}")
vlink_log("│ ENABLE_TEST_WARN: ${ENABLE_TEST_WARN}")
vlink_log("│ ENABLE_TEST_SANITIZE: ${ENABLE_TEST_SANITIZE}")
vlink_log("│ ENABLE_TEST_COVERAGE: ${ENABLE_TEST_COVERAGE}")
vlink_log("│ SELECT_LOG_BACKEND: ${SELECT_LOG_BACKEND}")
vlink_log("└────────────────────────────────────────────────────────────────────────────────")
message("")
install(FILES ${VLINK_INFO_FILE} DESTINATION ${INSTALL_CONFIG_DIR}/)
if("${VLINK_LIBRARIES}" STREQUAL "")
message(WARNING "VLINK_LIBRARIES is empty")
endif()
# cpack
include(cmake/package.cmake)