-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
529 lines (421 loc) · 15.4 KB
/
CMakeLists.txt
File metadata and controls
529 lines (421 loc) · 15.4 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
# Copyright (c) 2023-2024 Percona and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cmake_minimum_required(VERSION 3.20)
project(BinlogServer VERSION 0.1 LANGUAGES CXX)
# specify the C++ standard
add_library(binlog_server_compiler_flags INTERFACE)
target_compile_features(binlog_server_compiler_flags INTERFACE cxx_std_20)
target_include_directories(binlog_server_compiler_flags INTERFACE "${PROJECT_SOURCE_DIR}/src")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
include(compiler_warnings)
# add compiler warning flags just when building this project via
# the BUILD_INTERFACE genex
set(gcc_cxx "$<COMPILE_LANG_AND_ID:CXX,GNU>")
set(clang_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang>")
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
target_compile_options(binlog_server_compiler_flags INTERFACE
"$<${gcc_cxx}:$<BUILD_INTERFACE:${gcc_warnings}>>"
"$<${clang_cxx}:$<BUILD_INTERFACE:${clang_warnings}>>"
"$<${msvc_cxx}:$<BUILD_INTERFACE:${msvc_warnings}>>"
)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(WITH_STDLIB_LIBCXX_DEFAULT ON)
else()
set(WITH_STDLIB_LIBCXX_DEFAULT OFF)
endif()
option(WITH_STDLIB_LIBCXX "Use libc++ standard library" ${WITH_STDLIB_LIBCXX_DEFAULT})
if(WITH_STDLIB_LIBCXX)
message(STATUS "Using libc++ standard library")
set(libcxx_options "-stdlib=libc++")
else()
message(STATUS "Using libstdc++ standard library")
set(libcxx_options "-stdlib=libstdc++")
endif()
target_compile_options(binlog_server_compiler_flags INTERFACE
"$<${clang_cxx}:$<BUILD_INTERFACE:${libcxx_options}>>"
)
target_link_options(binlog_server_compiler_flags INTERFACE
"$<${clang_cxx}:$<BUILD_INTERFACE:${libcxx_options}>>"
)
endif()
option(WITH_ASAN "Enable Address Sanitizer" OFF)
if(WITH_ASAN)
# By default during the build time, on both GCC anf Clang, LeakSanitized is
# enabled by default when AddressSanitizer is enabled. However, in runtime
# it is enabled by default only on Linux platforms. Therefore, on MacOS,
# the executable needs to be run with 'ASAN_OPTIONS=detect_leaks=1'.
# Also AddressSanitizerUseAfterScope is also enabled by default both during
# the build time and in runtime, so there is no need to specify
# '-fsanitize-address-use-after-scope' explicitly or modify 'ASAN_OPTIONS'
target_compile_options(binlog_server_compiler_flags INTERFACE "-fsanitize=address")
target_link_options(binlog_server_compiler_flags INTERFACE "-fsanitize=address")
endif()
find_package(Boost 1.90.0 EXACT REQUIRED COMPONENTS url json)
find_package(MySQL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(AWSSDK 1.11.774 EXACT REQUIRED COMPONENTS s3-crt)
# various utility files
set(util_source_files
src/util/bnf_parser_helpers.hpp
src/util/bounded_string_storage_fwd.hpp
src/util/bounded_string_storage.hpp
src/util/byte_span_fwd.hpp
src/util/byte_span.hpp
src/util/byte_span_extractors.hpp
src/util/byte_span_inserters.hpp
src/util/byte_span_packed_int_constants.hpp
src/util/command_line_helpers_fwd.hpp
src/util/command_line_helpers.hpp
src/util/command_line_helpers.cpp
src/util/common_optional_types.hpp
src/util/conversion_helpers.hpp
src/util/composite_name_fwd.hpp
src/util/composite_name.hpp
src/util/ctime_timestamp_fwd.hpp
src/util/ctime_timestamp.hpp
src/util/ctime_timestamp.cpp
src/util/ctime_timestamp_range_fwd.hpp
src/util/ctime_timestamp_range.hpp
src/util/ctime_timestamp_range.cpp
src/util/crc_helpers.hpp
src/util/crc_helpers.cpp
src/util/ct_string.hpp
src/util/exception_location_helpers.hpp
src/util/flag_set_fwd.hpp
src/util/flag_set.hpp
src/util/impl_helpers.hpp
src/util/mixin_exception_adapter.hpp
src/util/nv_tuple_fwd.hpp
src/util/nv_tuple.hpp
src/util/nv_tuple_json_support.hpp
src/util/nv_tuple_from_json.hpp
src/util/nv_tuple_to_json.hpp
src/util/redirectable.hpp
src/util/semantic_version_fwd.hpp
src/util/semantic_version.hpp
src/util/semantic_version.cpp
)
add_library(lib_util STATIC ${util_source_files})
target_link_libraries(lib_util
PUBLIC
Boost::headers Boost::json
PRIVATE
binlog_server_compiler_flags
ZLIB::ZLIB
)
# it is not possible to propagate CXX_EXTENSIONS and CXX_STANDARD_REQUIRED
# via interface library (binlog_server_compiler_flags)
set_target_properties(lib_util PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
add_library(binsrv::lib_util ALIAS lib_util)
# mysql wrapper library files
set(easymysql_source_files
src/easymysql/core_error_helpers_private.hpp
src/easymysql/core_error_helpers_private.cpp
src/easymysql/core_error.hpp
src/easymysql/core_error.cpp
src/easymysql/connection_deimpl_private.hpp
src/easymysql/connection_fwd.hpp
src/easymysql/connection.hpp
src/easymysql/connection.cpp
src/easymysql/connection_config_fwd.hpp
src/easymysql/connection_config.hpp
src/easymysql/connection_config.cpp
src/easymysql/library_fwd.hpp
src/easymysql/library.hpp
src/easymysql/library.cpp
src/easymysql/ssl_config_fwd.hpp
src/easymysql/ssl_config.hpp
src/easymysql/ssl_mode_type_fwd.hpp
src/easymysql/ssl_mode_type.hpp
src/easymysql/tls_config_fwd.hpp
src/easymysql/tls_config.hpp
)
add_library(lib_easymysql STATIC ${easymysql_source_files})
target_link_libraries(lib_easymysql
PUBLIC
binsrv::lib_util
PRIVATE
binlog_server_compiler_flags
MySQL::client
)
# it is not possible to propagate CXX_EXTENSIONS and CXX_STANDARD_REQUIRED
# via interface library (binlog_server_compiler_flags)
set_target_properties(lib_easymysql PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
add_library(binsrv::lib_easymysql ALIAS lib_easymysql)
# gtid data structure files
set(gtids_source_files
src/binsrv/gtids/common_types.hpp
src/binsrv/gtids/gtid_fwd.hpp
src/binsrv/gtids/gtid.hpp
src/binsrv/gtids/gtid.cpp
src/binsrv/gtids/gtid_set_fwd.hpp
src/binsrv/gtids/gtid_set.hpp
src/binsrv/gtids/gtid_set.cpp
src/binsrv/gtids/tag_fwd.hpp
src/binsrv/gtids/tag.hpp
src/binsrv/gtids/tag.cpp
src/binsrv/gtids/uuid_fwd.hpp
src/binsrv/gtids/uuid.hpp
src/binsrv/gtids/uuid.cpp
)
add_library(lib_gtids STATIC ${gtids_source_files})
target_link_libraries(lib_gtids
PUBLIC
binsrv::lib_util
Boost::headers
PRIVATE
binlog_server_compiler_flags
)
# it is not possible to propagate CXX_EXTENSIONS and CXX_STANDARD_REQUIRED
# via interface library (binlog_server_compiler_flags)
set_target_properties(lib_gtids PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
add_library(binsrv::lib_gtids ALIAS lib_gtids)
set(events_source_files
# binlog event data structure files
src/binsrv/events/anonymous_gtid_log_body_impl_fwd.hpp
src/binsrv/events/anonymous_gtid_log_body_impl.hpp
src/binsrv/events/anonymous_gtid_log_post_header_impl_fwd.hpp
src/binsrv/events/anonymous_gtid_log_post_header_impl.hpp
src/binsrv/events/checksum_algorithm_type_fwd.hpp
src/binsrv/events/checksum_algorithm_type.hpp
src/binsrv/events/code_type_fwd.hpp
src/binsrv/events/code_type.hpp
src/binsrv/events/common_header_fwd.hpp
src/binsrv/events/common_header.hpp
src/binsrv/events/common_header.cpp
src/binsrv/events/common_header_view_fwd.hpp
src/binsrv/events/common_header_view.hpp
src/binsrv/events/common_header_view.cpp
src/binsrv/events/common_header_flag_type_fwd.hpp
src/binsrv/events/common_header_flag_type.hpp
src/binsrv/events/composite_binlog_name_fwd.hpp
src/binsrv/events/composite_binlog_name.hpp
src/binsrv/events/composite_binlog_name.cpp
src/binsrv/events/empty_body_fwd.hpp
src/binsrv/events/empty_body.hpp
src/binsrv/events/empty_body.cpp
src/binsrv/events/empty_post_header_fwd.hpp
src/binsrv/events/empty_post_header.hpp
src/binsrv/events/empty_post_header.cpp
src/binsrv/events/event_fwd.hpp
src/binsrv/events/event.hpp
src/binsrv/events/event.cpp
src/binsrv/events/event_view_fwd.hpp
src/binsrv/events/event_view.hpp
src/binsrv/events/event_view.cpp
src/binsrv/events/footer_fwd.hpp
src/binsrv/events/footer.hpp
src/binsrv/events/footer.cpp
src/binsrv/events/footer_view_fwd.hpp
src/binsrv/events/footer_view.hpp
src/binsrv/events/footer_view.cpp
src/binsrv/events/format_description_body_impl_fwd.hpp
src/binsrv/events/format_description_body_impl.hpp
src/binsrv/events/format_description_body_impl.cpp
src/binsrv/events/format_description_post_header_impl_fwd.hpp
src/binsrv/events/format_description_post_header_impl.hpp
src/binsrv/events/format_description_post_header_impl.cpp
src/binsrv/events/generic_body_fwd.hpp
src/binsrv/events/generic_body.hpp
src/binsrv/events/generic_post_header_fwd.hpp
src/binsrv/events/generic_post_header.hpp
src/binsrv/events/gtid_log_flag_type_fwd.hpp
src/binsrv/events/gtid_log_flag_type.hpp
src/binsrv/events/gtid_log_body_fwd.hpp
src/binsrv/events/gtid_log_body.hpp
src/binsrv/events/gtid_log_body.cpp
src/binsrv/events/gtid_log_body_impl_fwd.hpp
src/binsrv/events/gtid_log_body_impl.hpp
src/binsrv/events/gtid_log_post_header_fwd.hpp
src/binsrv/events/gtid_log_post_header.hpp
src/binsrv/events/gtid_log_post_header.cpp
src/binsrv/events/gtid_log_post_header_impl_fwd.hpp
src/binsrv/events/gtid_log_post_header_impl.hpp
src/binsrv/events/gtid_tagged_log_body_impl_fwd.hpp
src/binsrv/events/gtid_tagged_log_body_impl.hpp
src/binsrv/events/gtid_tagged_log_body_impl.cpp
src/binsrv/events/gtid_tagged_log_post_header_impl_fwd.hpp
src/binsrv/events/gtid_tagged_log_post_header_impl.hpp
src/binsrv/events/previous_gtids_log_body_impl_fwd.hpp
src/binsrv/events/previous_gtids_log_body_impl.hpp
src/binsrv/events/previous_gtids_log_body_impl.cpp
src/binsrv/events/previous_gtids_log_post_header_impl_fwd.hpp
src/binsrv/events/previous_gtids_log_post_header_impl.hpp
src/binsrv/events/protocol_traits_fwd.hpp
src/binsrv/events/protocol_traits.hpp
src/binsrv/events/protocol_traits.cpp
src/binsrv/events/reader_context_fwd.hpp
src/binsrv/events/reader_context.hpp
src/binsrv/events/reader_context.cpp
src/binsrv/events/rotate_body_impl_fwd.hpp
src/binsrv/events/rotate_body_impl.hpp
src/binsrv/events/rotate_body_impl.cpp
src/binsrv/events/rotate_post_header_impl_fwd.hpp
src/binsrv/events/rotate_post_header_impl.hpp
src/binsrv/events/rotate_post_header_impl.cpp
src/binsrv/events/stop_body_impl_fwd.hpp
src/binsrv/events/stop_body_impl.hpp
src/binsrv/events/stop_post_header_impl_fwd.hpp
src/binsrv/events/stop_post_header_impl.hpp
src/binsrv/events/unknown_body_fwd.hpp
src/binsrv/events/unknown_body.hpp
src/binsrv/events/unknown_body.cpp
src/binsrv/events/unknown_post_header_fwd.hpp
src/binsrv/events/unknown_post_header.hpp
src/binsrv/events/unknown_post_header.cpp
)
add_library(lib_events STATIC ${events_source_files})
target_link_libraries(lib_events
PUBLIC
binsrv::lib_util
binsrv::lib_gtids
Boost::headers
PRIVATE
binlog_server_compiler_flags
)
# it is not possible to propagate CXX_EXTENSIONS and CXX_STANDARD_REQUIRED
# via interface library (binlog_server_compiler_flags)
set_target_properties(lib_events PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
add_library(binsrv::lib_events ALIAS lib_events)
set(models_source_files
# models files
src/binsrv/models/binlog_file_record_fwd.hpp
src/binsrv/models/binlog_file_record.hpp
src/binsrv/models/error_response_fwd.hpp
src/binsrv/models/error_response.hpp
src/binsrv/models/error_response.cpp
src/binsrv/models/response_status_type_fwd.hpp
src/binsrv/models/response_status_type.hpp
src/binsrv/models/search_response_fwd.hpp
src/binsrv/models/search_response.hpp
src/binsrv/models/search_response.cpp
)
add_library(lib_models STATIC ${models_source_files})
target_link_libraries(lib_models
PUBLIC
binsrv::lib_util
binsrv::lib_gtids
PRIVATE
binlog_server_compiler_flags
Boost::json
)
# it is not possible to propagate CXX_EXTENSIONS and CXX_STANDARD_REQUIRED
# via interface library (binlog_server_compiler_flags)
set_target_properties(lib_models PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
add_library(binsrv::lib_models ALIAS lib_models)
set(binsrv_source_files
# main application files
src/app.cpp
src/app_version.hpp
# binlog files
src/binsrv/basic_logger_fwd.hpp
src/binsrv/basic_logger.hpp
src/binsrv/basic_logger.cpp
src/binsrv/basic_storage_backend_fwd.hpp
src/binsrv/basic_storage_backend.hpp
src/binsrv/basic_storage_backend.cpp
src/binsrv/binlog_file_metadata_fwd.hpp
src/binsrv/binlog_file_metadata.hpp
src/binsrv/binlog_file_metadata.cpp
src/binsrv/cout_logger.hpp
src/binsrv/cout_logger.cpp
src/binsrv/exception_handling_helpers.hpp
src/binsrv/exception_handling_helpers.cpp
src/binsrv/file_logger.hpp
src/binsrv/file_logger.cpp
src/binsrv/filesystem_storage_backend.hpp
src/binsrv/filesystem_storage_backend.cpp
src/binsrv/log_severity_fwd.hpp
src/binsrv/log_severity.hpp
src/binsrv/logger_config_fwd.hpp
src/binsrv/logger_config.hpp
src/binsrv/logger_factory.hpp
src/binsrv/logger_factory.cpp
src/binsrv/main_config_fwd.hpp
src/binsrv/main_config.hpp
src/binsrv/main_config.cpp
src/binsrv/operation_mode_type_fwd.hpp
src/binsrv/operation_mode_type.hpp
src/binsrv/replication_config_fwd.hpp
src/binsrv/replication_config.hpp
src/binsrv/replication_config.cpp
src/binsrv/replication_mode_type_fwd.hpp
src/binsrv/replication_mode_type.hpp
src/binsrv/rewrite_config_fwd.hpp
src/binsrv/rewrite_config.hpp
src/binsrv/rewrite_config.cpp
src/binsrv/size_unit_fwd.hpp
src/binsrv/size_unit.hpp
src/binsrv/size_unit.cpp
src/binsrv/s3_error_helpers_private.hpp
src/binsrv/s3_error_helpers_private.cpp
src/binsrv/s3_error.hpp
src/binsrv/s3_error.cpp
src/binsrv/s3_storage_backend.hpp
src/binsrv/s3_storage_backend.cpp
src/binsrv/storage_fwd.hpp
src/binsrv/storage.hpp
src/binsrv/storage.cpp
src/binsrv/storage_backend_factory.hpp
src/binsrv/storage_backend_factory.cpp
src/binsrv/storage_backend_type_fwd.hpp
src/binsrv/storage_backend_type.hpp
src/binsrv/storage_config_fwd.hpp
src/binsrv/storage_config.hpp
src/binsrv/storage_metadata_fwd.hpp
src/binsrv/storage_metadata.hpp
src/binsrv/storage_metadata.cpp
src/binsrv/time_unit_fwd.hpp
src/binsrv/time_unit.hpp
src/binsrv/time_unit.cpp
)
add_executable(binlog_server ${binsrv_source_files})
target_link_libraries(binlog_server
PRIVATE
binlog_server_compiler_flags
binsrv::lib_util
binsrv::lib_easymysql
binsrv::lib_gtids
binsrv::lib_events
binsrv::lib_models
Boost::headers Boost::json Boost::url
aws-cpp-sdk-s3-crt
)
# it is not possible to propagate CXX_EXTENSIONS and CXX_STANDARD_REQUIRED
# via interface library (binlog_server_compiler_flags)
set_target_properties(binlog_server PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()