-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
577 lines (507 loc) · 16.2 KB
/
CMakeLists.txt
File metadata and controls
577 lines (507 loc) · 16.2 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
cmake_minimum_required(VERSION 3.5)
project(dbps_server_prj)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Build all targets (including STATIC libs) with position independent code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Build options
option(BUILD_TESTS "Build test executables" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
# Enable CTest and GoogleTest integration
enable_testing()
include(CTest)
# =============================================================================
# Dependencies
# =============================================================================
include(FetchContent)
# Crow is a lightweight framework for running web APIs
FetchContent_Declare(
crow
GIT_REPOSITORY https://github.com/CrowCpp/crow.git
GIT_TAG v1.0+2
)
# cppcodec is a header-only base64 library
FetchContent_Declare(
cppcodec
GIT_REPOSITORY https://github.com/tplgy/cppcodec.git
GIT_TAG 8019b8b580f8573c33c50372baec7039dfe5a8ce # points to the head of main as of 11/11/2025
)
# httplib is a header-only HTTP client library
FetchContent_Declare(
httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG v0.14.3
)
# nlohmann/json is a header-only JSON library
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
# tcb/span - header-only span implementation (match Arrow's approach)
FetchContent_Declare(
tcb_span_upstream
GIT_REPOSITORY https://github.com/tcbrindle/span.git
GIT_TAG master
)
FetchContent_GetProperties(tcb_span_upstream)
if(NOT tcb_span_upstream_POPULATED)
FetchContent_Populate(tcb_span_upstream)
endif()
add_library(tcb_span INTERFACE)
target_include_directories(tcb_span INTERFACE ${tcb_span_upstream_SOURCE_DIR}/include)
# cxxopts is a header-only command line parser
FetchContent_Declare(
cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
GIT_TAG v3.1.0
)
# Google Test for unit testing
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
# jwt-cpp is a header-only JWT library
FetchContent_Declare(
jwt-cpp
GIT_REPOSITORY https://github.com/Thalhammer/jwt-cpp.git
GIT_TAG master
)
# Snappy is a fast compression/decompression library
FetchContent_Declare(
snappy
GIT_REPOSITORY https://github.com/google/snappy.git
GIT_TAG 1.2.2
)
# Fetch dependencies
# Disable dependency tests for cppcodec
# Dependency tests are picked up by GTest/CTest.
# This disabling is needed as not all of the cppcodec tests pass, and we want to avoid
# generating noise in the tests where the noise is caused by the third-party tests.
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(cppcodec)
set(BUILD_TESTING ON CACHE BOOL "" FORCE)
# Disable Snappy tests to avoid conflicts with our GoogleTest
# Snappy includes its own GoogleTest which conflicts with our FetchContent GoogleTest
set(SNAPPY_BUILD_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(snappy)
set(SNAPPY_BUILD_TESTS ON CACHE BOOL "" FORCE)
# Suppress warnings from Snappy's source code
if(TARGET snappy)
target_compile_options(snappy PRIVATE
-Wno-sign-compare
)
endif()
FetchContent_MakeAvailable(crow httplib nlohmann_json cxxopts googletest jwt-cpp)
# Make GoogleTest helper macros available (gtest_discover_tests)
include(GoogleTest)
# =============================================================================
# Library Definitions
# =============================================================================
# Common utilities library (depends on crow for JSON parsing)
add_library(dbps_common_lib STATIC
src/common/json_request.cpp
src/common/enum_utils.cpp
)
target_include_directories(dbps_common_lib PUBLIC
src/common
${CMAKE_BINARY_DIR}/_deps/crow-src/include
${CMAKE_BINARY_DIR}/_deps/cppcodec-src
)
target_link_libraries(dbps_common_lib PUBLIC tcb_span)
# Typed buffer processing library (header-only)
add_library(dbps_byte_buffer_lib INTERFACE)
target_include_directories(dbps_byte_buffer_lib INTERFACE
src/processing
src/common
)
target_link_libraries(dbps_byte_buffer_lib INTERFACE tcb_span)
# Server components library
add_library(dbps_server_lib STATIC
src/processing/encryption_sequencer.cpp
src/server/auth_utils.cpp
src/processing/parquet_utils.cpp
src/processing/compression_utils.cpp
src/processing/encryptors/basic_xor_encryptor.cpp
)
target_link_libraries(dbps_server_lib PUBLIC dbps_common_lib snappy)
target_include_directories(dbps_server_lib PUBLIC
src/server
src/processing
src/processing/encryptors
src/common
${CMAKE_BINARY_DIR}/_deps/cppcodec-src
${CMAKE_BINARY_DIR}/_deps/jwt-cpp-src/include
${CMAKE_BINARY_DIR}/_deps/nlohmann_json-src/include
${CMAKE_BINARY_DIR}/_deps/snappy-src
)
# Find and link OpenSSL (required by jwt-cpp)
find_package(OpenSSL REQUIRED)
target_link_libraries(dbps_server_lib PUBLIC OpenSSL::SSL OpenSSL::Crypto)
# Client components library (depends on httplib, nlohmann/json, and cppcodec)
add_library(dbps_client_lib STATIC
src/client/dbps_api_client.cpp
src/client/http_client_base.cpp
src/client/httplib_client.cpp
src/client/httplib_pool_registry.cpp
src/client/httplib_pooled_client.cpp
)
target_link_libraries(dbps_client_lib PUBLIC dbps_common_lib)
target_include_directories(dbps_client_lib PUBLIC
src/client
${CMAKE_BINARY_DIR}/_deps/httplib-src
${CMAKE_BINARY_DIR}/_deps/nlohmann_json-src/include
${CMAKE_BINARY_DIR}/_deps/cppcodec-src
)
target_link_libraries(dbps_client_lib PUBLIC tcb_span)
# Remote DBPA library
add_library(dbps_remote_lib STATIC
src/common/dbpa_remote.cpp
)
target_link_libraries(dbps_remote_lib PUBLIC
dbps_client_lib
dbps_common_lib
)
target_include_directories(dbps_remote_lib PUBLIC
${CMAKE_BINARY_DIR}/_deps/crow-src/include
${CMAKE_BINARY_DIR}/_deps/cppcodec-src
)
# Local DBPA library
add_library(dbps_local_lib STATIC
src/common/dbpa_local.cpp
)
target_link_libraries(dbps_local_lib PUBLIC
dbps_server_lib
dbps_common_lib
)
target_include_directories(dbps_local_lib PUBLIC
src/processing
${CMAKE_BINARY_DIR}/_deps/crow-src/include
${CMAKE_BINARY_DIR}/_deps/cppcodec-src
${CMAKE_BINARY_DIR}/_deps/nlohmann_json-src/include
)
# Ensure PIC on static libs that are linked into shared libraries
set_target_properties(dbps_common_lib dbps_server_lib dbps_local_lib
PROPERTIES POSITION_INDEPENDENT_CODE ON)
# =============================================================================
# Main Executables
# =============================================================================
# Main API server
add_executable(dbps_api_server src/server/dbps_api_server.cpp)
target_link_libraries(dbps_api_server
dbps_server_lib
dbps_common_lib
)
target_include_directories(dbps_api_server PRIVATE
${CMAKE_BINARY_DIR}/_deps/crow-src/include
${CMAKE_BINARY_DIR}/_deps/cxxopts-src/include
)
# DBPA Remote Test Script executable
add_executable(dbpa_remote_testapp src/scripts/dbpa_remote_testapp.cpp)
target_link_libraries(dbpa_remote_testapp
dbps_remote_lib
dbps_client_lib
dbps_common_lib
dbps_server_lib
)
target_include_directories(dbpa_remote_testapp PRIVATE
${CMAKE_BINARY_DIR}/_deps/cxxopts-src/include
src/processing
${CMAKE_BINARY_DIR}/_deps/snappy-src
)
# Performance Test Script executable
add_executable(performance_test src/scripts/performance_test.cpp)
target_link_libraries(performance_test
dbps_remote_lib
dbps_client_lib
dbps_common_lib
dbps_server_lib
dbps_local_lib
)
target_include_directories(performance_test PRIVATE
${CMAKE_BINARY_DIR}/_deps/cxxopts-src/include
src/processing
${CMAKE_BINARY_DIR}/_deps/snappy-src
)
# =============================================================================
# Test Executables
# =============================================================================
if(BUILD_TESTS)
# JSON request tests
add_executable(json_request_test src/common/json_request_test.cpp)
target_link_libraries(json_request_test
dbps_common_lib
gtest_main
)
target_include_directories(json_request_test PRIVATE
${CMAKE_BINARY_DIR}/_deps/crow-src/include
)
# Enum utils tests
add_executable(enum_utils_test src/common/enum_utils_test.cpp)
target_link_libraries(enum_utils_test
dbps_common_lib
gtest_main
)
# Encryption sequencer tests
add_executable(encryption_sequencer_test src/processing/encryption_sequencer_test.cpp)
target_link_libraries(encryption_sequencer_test
dbps_server_lib
dbps_common_lib
gtest_main
)
# Parquet utils tests
add_executable(parquet_utils_test src/processing/parquet_utils_test.cpp)
target_link_libraries(parquet_utils_test
dbps_server_lib
dbps_common_lib
gtest_main
)
target_include_directories(parquet_utils_test PRIVATE src/processing)
# Bytes utils tests
add_executable(bytes_utils_test src/common/bytes_utils_test.cpp)
target_link_libraries(bytes_utils_test
dbps_server_lib
dbps_common_lib
gtest_main
)
target_include_directories(bytes_utils_test PRIVATE src/server src/common)
# Compression utils tests
add_executable(compression_utils_test src/processing/compression_utils_test.cpp)
target_link_libraries(compression_utils_test
dbps_server_lib
dbps_common_lib
gtest_main
)
target_include_directories(compression_utils_test PRIVATE src/processing)
# Typed buffer tests
add_executable(typed_buffer_test src/processing/typed_buffer_test.cpp)
target_link_libraries(typed_buffer_test
dbps_byte_buffer_lib
gtest_main
)
target_include_directories(typed_buffer_test PRIVATE src/processing src/common)
# Typed buffer values tests
add_executable(typed_buffer_values_test src/processing/typed_buffer_values_test.cpp)
target_link_libraries(typed_buffer_values_test
dbps_byte_buffer_lib
gtest_main
)
target_include_directories(typed_buffer_values_test PRIVATE src/processing src/common)
# Basic encryptor tests
add_executable(basic_xor_encryptor_test src/processing/encryptors/basic_xor_encryptor_test.cpp)
target_link_libraries(basic_xor_encryptor_test
dbps_server_lib
dbps_common_lib
gtest_main
)
target_include_directories(basic_xor_encryptor_test PRIVATE src/processing src/processing/encryptors)
# Auth utils tests
add_executable(auth_utils_test src/server/auth_utils_test.cpp)
target_link_libraries(auth_utils_test
dbps_server_lib
dbps_common_lib
gtest_main
)
target_include_directories(auth_utils_test PRIVATE src/server)
# DBPA interface tests
add_executable(dbpa_interface_test src/common/dbpa_interface_test.cpp)
target_link_libraries(dbpa_interface_test
dbps_common_lib
gtest_main
)
# DBPA utils tests
add_executable(dbpa_utils_test src/common/dbpa_utils_test.cpp)
target_link_libraries(dbpa_utils_test
dbps_common_lib
gtest_main
)
# Client API tests
add_executable(dbps_api_client_test src/client/dbps_api_client_test.cpp)
target_link_libraries(dbps_api_client_test
dbps_client_lib
dbps_common_lib
gtest_main
)
target_include_directories(dbps_api_client_test PRIVATE
${CMAKE_BINARY_DIR}/_deps/crow-src/include
)
# Pool registry tests
add_executable(httplib_pool_registry_test src/client/httplib_pool_registry_test.cpp)
target_link_libraries(httplib_pool_registry_test
dbps_client_lib
dbps_common_lib
gtest_main
)
# Pooled client tests
add_executable(httplib_pooled_client_test src/client/httplib_pooled_client_test.cpp)
target_link_libraries(httplib_pooled_client_test
dbps_client_lib
dbps_common_lib
gtest_main
)
# Http client interface tests
add_executable(http_client_base_test src/client/http_client_base_test.cpp)
target_link_libraries(http_client_base_test
dbps_client_lib
dbps_common_lib
gtest_main
)
# Remote DBPA tests
add_executable(dbpa_remote_test src/common/dbpa_remote_test.cpp)
target_link_libraries(dbpa_remote_test
dbps_remote_lib
dbps_client_lib
dbps_common_lib
gtest_main
)
# Local DBPA tests
add_executable(dbpa_local_test src/common/dbpa_local_test.cpp)
target_link_libraries(dbpa_local_test
dbps_local_lib
dbps_server_lib
dbps_common_lib
gtest_main
)
endif()
# =============================================================================
# Shared Library (Client Library)
# =============================================================================
if(BUILD_SHARED_LIBS)
# Create dynamic library with core components
add_library(remote_agent_shared SHARED
src/common/dbps_remote_shared_lib_wrapper.cpp
src/common/dbpa_remote.cpp
src/client/dbps_api_client.cpp
src/client/http_client_base.cpp
src/client/httplib_client.cpp
src/common/json_request.cpp
)
# Set library properties
set_target_properties(remote_agent_shared PROPERTIES
VERSION 1.0.0
SOVERSION 1
OUTPUT_NAME "dbpsRemoteAgent"
)
# Link dependencies
target_link_libraries(remote_agent_shared
dbps_remote_lib
dbps_client_lib
dbps_common_lib
)
# Include directories for the library
target_include_directories(remote_agent_shared PUBLIC
${CMAKE_BINARY_DIR}/_deps/cppcodec-src
${CMAKE_BINARY_DIR}/_deps/crow-src/include
${CMAKE_BINARY_DIR}/_deps/httplib-src
src/common
)
# Create dynamic library for local agent
add_library(local_agent_shared SHARED
src/common/dbps_local_shared_lib_wrapper.cpp
)
# Set library properties for local client
set_target_properties(local_agent_shared PROPERTIES
VERSION 1.0.0
SOVERSION 1
OUTPUT_NAME "dbpsLocalAgent"
)
# Link dependencies
target_link_libraries(local_agent_shared
PRIVATE dbps_local_lib
)
# Include directories for the local library
target_include_directories(local_agent_shared PUBLIC
${CMAKE_BINARY_DIR}/_deps/cppcodec-src
${CMAKE_BINARY_DIR}/_deps/crow-src/include
src/common
src/server
)
endif()
# =============================================================================
# Custom Targets
# =============================================================================
# Libraries target
add_custom_target(libraries
DEPENDS
dbps_common_lib
dbps_byte_buffer_lib
dbps_server_lib
dbps_client_lib
dbps_remote_lib
dbps_local_lib
COMMENT "Building all libraries"
)
add_custom_target(shared_libraries
DEPENDS
remote_agent_shared
local_agent_shared
COMMENT "Building all shared libraries"
)
# Main executables target
add_custom_target(executables
DEPENDS
dbps_api_server
dbpa_remote_testapp
performance_test
COMMENT "Building main executables"
)
# Tests target
if(BUILD_TESTS)
add_custom_target(tests
DEPENDS
json_request_test
enum_utils_test
encryption_sequencer_test
parquet_utils_test
bytes_utils_test
compression_utils_test
typed_buffer_test
typed_buffer_values_test
basic_xor_encryptor_test
auth_utils_test
dbpa_interface_test
dbpa_utils_test
dbps_api_client_test
dbpa_remote_test
dbpa_local_test
httplib_pool_registry_test
httplib_pooled_client_test
http_client_base_test
COMMENT "Building all tests"
)
# Register tests with CTest via GoogleTest discovery
gtest_discover_tests(json_request_test)
gtest_discover_tests(enum_utils_test)
gtest_discover_tests(encryption_sequencer_test)
gtest_discover_tests(parquet_utils_test)
gtest_discover_tests(bytes_utils_test)
gtest_discover_tests(compression_utils_test)
gtest_discover_tests(typed_buffer_test)
gtest_discover_tests(typed_buffer_values_test)
gtest_discover_tests(basic_xor_encryptor_test)
gtest_discover_tests(auth_utils_test)
gtest_discover_tests(dbpa_interface_test)
gtest_discover_tests(dbpa_utils_test)
gtest_discover_tests(dbps_api_client_test)
gtest_discover_tests(dbpa_remote_test)
gtest_discover_tests(dbpa_local_test)
gtest_discover_tests(httplib_pool_registry_test)
gtest_discover_tests(httplib_pooled_client_test)
gtest_discover_tests(http_client_base_test)
endif()
# All target (everything)
add_custom_target(all_targets
DEPENDS
libraries
executables
COMMENT "Building all targets"
)
# Add tests to all_targets if enabled
if(BUILD_TESTS)
add_dependencies(all_targets tests)
endif()
# Add client shared library to all_targets if enabled
if(BUILD_SHARED_LIBS)
add_dependencies(all_targets shared_libraries)
endif()