forked from fluent/fluent-bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
593 lines (522 loc) · 10.7 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
add_definitions(-DFLB_CORE=1)
# Core Source
set(src
${src}
flb_mp.c
flb_kv.c
flb_api.c
flb_csv.c
flb_lib.c
flb_log.c
flb_env.c
flb_file.c
flb_uri.c
flb_hash_table.c
flb_help.c
flb_pack.c
flb_pack_gelf.c
flb_sds.c
flb_sds_list.c
flb_pipe.c
flb_meta.c
flb_kernel.c
flb_custom.c
flb_input.c
flb_input_chunk.c
flb_input_log.c
flb_input_metric.c
flb_input_trace.c
flb_input_blob.c
flb_input_thread.c
flb_filter.c
flb_output.c
flb_output_thread.c
flb_config.c
flb_config_map.c
flb_socket.c
flb_network.c
flb_utils.c
flb_slist.c
flb_engine.c
flb_engine_dispatch.c
flb_task.c
flb_unescape.c
flb_scheduler.c
flb_io.c
flb_storage.c
flb_connection.c
flb_downstream.c
flb_upstream.c
flb_upstream_ha.c
flb_upstream_node.c
flb_router.c
flb_worker.c
flb_coro.c
flb_time.c
flb_sosreport.c
flb_hmac.c
flb_hash.c
flb_crypto.c
flb_random.c
flb_plugin.c
flb_gzip.c
flb_snappy.c
flb_compression.c
flb_http_common.c
flb_http_client_http1.c
flb_http_client_http2.c
flb_http_client.c
flb_callback.c
flb_strptime.c
flb_fstore.c
flb_thread_pool.c
flb_routes_mask.c
flb_typecast.c
flb_event.c
flb_base64.c
flb_ring_buffer.c
flb_log_event_decoder.c
flb_log_event_encoder.c
flb_log_event_encoder_primitives.c
flb_log_event_encoder_dynamic_field.c
flb_processor.c
flb_reload.c
flb_msgpack_append_message.c
flb_notification.c
flb_lock.c
)
# Config format
set(src
${src}
config_format/flb_config_format.c
config_format/flb_cf_fluentbit.c
)
if(FLB_HAVE_LIBYAML)
set(src
${src}
config_format/flb_cf_yaml.c
)
endif()
# Multiline subsystem
add_subdirectory(multiline)
set(src
${src}
${src_multiline}
)
if(FLB_SYSTEM_WINDOWS)
set(src
${src}
flb_dlfcn_win32.c
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W2")
endif()
if(FLB_PARSER)
set(src
${src}
flb_parser.c
flb_parser_regex.c
flb_parser_json.c
flb_parser_decoder.c
flb_parser_ltsv.c
flb_parser_logfmt.c
)
endif()
if(FLB_AVRO_ENCODER)
set(src
${src}
flb_avro.c
)
endif()
# Fluent Bit have TLS support
if(FLB_TLS)
# Register the TLS interface and functions
set(src
${src}
"tls/flb_tls.c"
"flb_oauth2.c"
)
# Make sure our output targets links to the TLS library
set(extra_libs
${extra_libs}
)
endif()
if(FLB_PROXY_GO)
set(src
${src}
"flb_plugin_proxy.c"
)
endif()
if(FLB_METRICS)
set(src
${src}
"flb_metrics.c"
"flb_metrics_exporter.c"
)
endif()
if(FLB_SIGNV4 AND FLB_TLS)
set(src
${src}
"flb_signv4.c"
"flb_signv4_ng.c"
)
endif()
if(FLB_HTTP_CLIENT_DEBUG)
set(src
${src}
"flb_http_client_debug.c"
)
endif()
if (FLB_AWS_ERROR_REPORTER)
set(src
${src}
"aws/flb_aws_error_reporter.c"
)
endif()
if(FLB_LUAJIT)
set(src
${src}
"flb_lua.c"
"flb_luajit.c"
)
endif()
if(FLB_IN_KAFKA OR FLB_OUT_KAFKA)
set(src
${src}
"flb_kafka.c"
)
endif()
# Link to libco
set(extra_libs
${extra_libs}
"co")
set(extra_libs
${extra_libs}
"rbtree")
if(FLB_JEMALLOC)
set(extra_libs
${extra_libs}
${JEMALLOC_LIBRARIES})
endif()
if(FLB_REGEX)
set(FLB_DEPS
${FLB_DEPS}
onigmo-static)
set(src
${src}
"flb_regex.c"
)
endif()
if(FLB_LUAJIT)
set(extra_libs
${extra_libs}
${LUAJIT_LIBRARIES})
endif()
if(FLB_SQLDB)
set(src
${src}
"flb_sqldb.c"
)
set(extra_libs
${extra_libs}
"sqlite3")
endif()
if(FLB_STATIC_CONF)
set(src
${src}
"flb_config_static.c"
)
endif()
if(FLB_CHUNK_TRACE)
set(src
${src}
"flb_chunk_trace.c"
)
endif()
include(CheckSymbolExists)
check_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
# Core dependencies
if(FLB_SYSTEM_WINDOWS)
set(FLB_DEPS
"ws2_32.lib"
"crypt32.lib"
"Bcrypt.lib"
"Shlwapi.lib"
)
else()
set(FLB_DEPS
${FLB_DEPS}
${CMAKE_DL_LIBS}
m
)
endif()
# Link timer library
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(FLB_DEPS
${FLB_DEPS}
rt
)
endif()
if(FLB_SYSTEM_MACOS)
set(FLB_DEPS
${FLB_DEPS}
"-framework Foundation"
"-framework IOKit"
"-framework Security"
)
endif()
# Record Accessor
# ---------------
# Make sure it dependency is enabled
if(FLB_RECORD_ACCESSOR AND NOT FLB_REGEX)
message(FATAL_ERROR
"FLB_RECORD_ACCESSOR depends on FLB_REGEX, "
"enable it with: -DFLB_REGEX=ON")
endif()
# Build record accessor files
if(FLB_RECORD_ACCESSOR)
set(src
${src}
"flb_record_accessor.c"
"flb_ra_key.c"
)
add_subdirectory(record_accessor)
endif()
# Stream Processor
if(FLB_STREAM_PROCESSOR)
add_subdirectory(stream_processor)
endif()
# AWS specific
if(FLB_AWS)
add_subdirectory(aws)
endif()
# HTTP Server
if(FLB_HTTP_SERVER)
add_subdirectory(http_server)
endif()
# Proxy interfaces
add_subdirectory(proxy)
set(FLB_PROXY_PLUGINS "")
if(FLB_PROXY_GO)
set(FLB_PROXY_PLUGINS ${FLB_PROXY_PLUGINS} flb-plugin-proxy-go)
endif()
# WASM runtime
if(FLB_WASM)
add_subdirectory(wasm)
endif()
# WAMRC compiler
if(FLB_WAMRC)
add_subdirectory(wamrc)
endif()
# HTTP Server
if(FLB_HTTP_SERVER)
set(FLB_DEPS
${FLB_DEPS}
flb-http-server)
endif()
# AVRO Encoding
if(FLB_AVRO_ENCODER)
set(FLB_DEPS
${FLB_DEPS}
avro-static
jansson
)
endif()
# WASM runtime
if(FLB_WASM)
set(FLB_DEPS
${FLB_DEPS}
vmlib-static
flb-wasm-static)
endif()
# Set static dependencies
set(FLB_DEPS
${FLB_DEPS}
cfl-static
fluent-otel-proto
cprofiles-static
cmetrics-static
ctraces-static
mk_core
jsmn
msgpack-c-static
mpack-static
chunkio-static
miniz
${FLB_PLUGINS}
${FLB_PROXY_PLUGINS}
${extra_libs}
${LIBCARES_LIBRARIES}
snappy-c
lwrb
${NGHTTP2_LIBRARIES}
)
if(OPENSSL_FOUND)
set(FLB_DEPS
${FLB_DEPS}
OpenSSL::SSL
)
endif()
# libyaml
if(FLB_HAVE_LIBYAML)
set(FLB_DEPS
${FLB_DEPS}
yaml
)
endif()
# UTF8 Encoding
if(FLB_UTF8_ENCODER)
set(FLB_DEPS
${FLB_DEPS}
tutf8e
)
endif()
# AWS specific
if(FLB_AWS)
set(FLB_DEPS
${FLB_DEPS}
flb-aws
)
endif()
# Record Accessor
if(FLB_RECORD_ACCESSOR)
set(FLB_DEPS
${FLB_DEPS}
flb-ra-parser
)
endif()
# Stream Processor
if(FLB_STREAM_PROCESSOR)
set(FLB_DEPS
${FLB_DEPS}
flb-sp
)
endif()
if (MSVC)
set(flb_rc_files
${CMAKE_CURRENT_BINARY_DIR}/version.rc
)
endif()
# Shared Library
if(FLB_SHARED_LIB)
add_library(fluent-bit-shared SHARED ${src})
add_sanitizers(fluent-bit-shared)
set_target_properties(fluent-bit-shared
PROPERTIES OUTPUT_NAME fluent-bit)
# Windows doesn't provide pthread (see winpthreads.c in mk_core).
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
target_link_libraries(fluent-bit-shared ${FLB_DEPS})
else()
target_link_libraries(fluent-bit-shared ${FLB_DEPS} -lpthread)
endif()
if (MSVC)
set_target_properties(fluent-bit-shared
PROPERTIES PDB_NAME fluent-bit.dll)
target_link_options(fluent-bit-shared
PUBLIC /pdb:$<TARGET_PDB_FILE:fluent-bit-shared>)
endif()
# Library install routines
install(TARGETS fluent-bit-shared
LIBRARY DESTINATION ${FLB_INSTALL_LIBDIR}
COMPONENT library
RUNTIME DESTINATION ${FLB_INSTALL_BINDIR})
endif()
# Static Library
add_library(fluent-bit-static STATIC ${src})
add_sanitizers(fluent-bit-static)
target_link_libraries(fluent-bit-static ${FLB_DEPS})
if(MSVC)
# Rename the output for Windows environment to avoid naming issues
set_target_properties(fluent-bit-static PROPERTIES OUTPUT_NAME libfluent-bit)
else()
set_target_properties(fluent-bit-static PROPERTIES OUTPUT_NAME fluent-bit)
endif(MSVC)
if(FLB_JEMALLOC)
target_link_libraries(fluent-bit-static ${JEMALLOC_LIBRARIES})
endif()
# Binary / Executable
if(FLB_BINARY)
find_package (Threads)
if (FLB_SYSTEM_WINDOWS)
add_executable(fluent-bit-bin fluent-bit.c flb_dump.c win32/winsvc.c ${flb_rc_files})
else()
add_executable(fluent-bit-bin fluent-bit.c flb_dump.c)
endif()
add_sanitizers(fluent-bit-bin)
if(FLB_STATIC_CONF)
add_dependencies(fluent-bit-bin flb-static-conf)
endif()
if(FLB_REGEX)
target_link_libraries(fluent-bit-bin onigmo-static)
endif()
if(FLB_JEMALLOC)
target_link_libraries(fluent-bit-bin ${JEMALLOC_LIBRARIES})
endif()
if(FLB_BACKTRACE)
add_definitions(-DFLB_DUMP_STACKTRACE=1)
target_link_libraries(fluent-bit-bin ${LIBBACKTRACE_LIBRARIES})
endif()
target_link_libraries(fluent-bit-bin fluent-bit-static ${CMAKE_THREAD_LIBS_INIT})
set_target_properties(fluent-bit-bin
PROPERTIES
OUTPUT_NAME ${FLB_OUT_NAME}
ENABLE_EXPORTS ON)
install(TARGETS fluent-bit-bin RUNTIME DESTINATION ${FLB_INSTALL_BINDIR} COMPONENT binary)
# Include PDB file (if available)
if (MSVC)
target_link_options(fluent-bit-bin
PUBLIC /pdb:$<TARGET_PDB_FILE:fluent-bit-bin>)
install(FILES $<TARGET_PDB_FILE:fluent-bit-bin>
DESTINATION "${FLB_INSTALL_BINDIR}")
endif()
# Detect init system, install upstart, systemd or init.d script
# Handle issues with detection on some systems during build
if(NOT SYSTEMD_UNITDIR AND IS_DIRECTORY /lib/systemd/system)
set(SYSTEMD_UNITDIR /lib/systemd/system)
endif()
if(SYSTEMD_UNITDIR)
set(FLB_SYSTEMD_SCRIPT "${PROJECT_SOURCE_DIR}/init/${FLB_OUT_NAME}.service")
configure_file(
"${PROJECT_SOURCE_DIR}/init/systemd.in"
${FLB_SYSTEMD_SCRIPT}
)
install(FILES ${FLB_SYSTEMD_SCRIPT} COMPONENT binary DESTINATION ${SYSTEMD_UNITDIR})
install(DIRECTORY DESTINATION ${FLB_INSTALL_CONFDIR} COMPONENT binary)
elseif(IS_DIRECTORY /usr/share/upstart)
set(FLB_UPSTART_SCRIPT "${PROJECT_SOURCE_DIR}/init/${FLB_OUT_NAME}.conf")
configure_file(
"${PROJECT_SOURCE_DIR}/init/upstart.in"
${FLB_UPSTART_SCRIPT}
)
install(FILES ${FLB_UPSTART_SCRIPT} COMPONENT binary DESTINATION /etc/init)
install(DIRECTORY DESTINATION COMPONENT binary ${FLB_INSTALL_CONFDIR})
else()
# FIXME: should we support Sysv init script ?
endif()
if(FLB_SYSTEM_WINDOWS)
install(FILES
"${PROJECT_SOURCE_DIR}/conf/fluent-bit-win32.conf"
DESTINATION ${FLB_INSTALL_CONFDIR}
COMPONENT binary
RENAME "${FLB_OUT_NAME}.conf")
elseif(FLB_SYSTEM_MACOS)
install(FILES
"${PROJECT_SOURCE_DIR}/conf/fluent-bit-macos.conf"
DESTINATION ${FLB_INSTALL_CONFDIR}
COMPONENT binary
RENAME "${FLB_OUT_NAME}.conf")
else()
install(FILES
"${PROJECT_SOURCE_DIR}/conf/fluent-bit.conf"
DESTINATION ${FLB_INSTALL_CONFDIR}
COMPONENT binary
RENAME "${FLB_OUT_NAME}.conf")
endif()
install(FILES
"${PROJECT_SOURCE_DIR}/conf/parsers.conf"
COMPONENT binary
DESTINATION ${FLB_INSTALL_CONFDIR})
install(FILES
"${PROJECT_SOURCE_DIR}/conf/plugins.conf"
COMPONENT binary
DESTINATION ${FLB_INSTALL_CONFDIR})
endif()