-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
215 lines (203 loc) · 5.74 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
cmake_minimum_required(VERSION 3.5)
project(fluent_bit_vendor)
find_package(ament_cmake REQUIRED)
set(cmake_commands)
set(cmake_configure_args -Wno-dev)
if(WIN32)
if(DEFINED CMAKE_GENERATOR)
list(APPEND cmake_configure_args -G ${CMAKE_GENERATOR})
endif()
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^(x86_|x86-|AMD|amd|x)64$")
list(APPEND cmake_configure_args -A x64)
endif()
endif()
if(DEFINED CMAKE_BUILD_TYPE)
if(WIN32)
build_command(_build_command CONFIGURATION ${CMAKE_BUILD_TYPE})
list(APPEND cmake_commands "BUILD_COMMAND ${_build_command}")
else()
list(APPEND cmake_configure_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
endif()
if(DEFINED CMAKE_TOOLCHAIN_FILE)
list(APPEND cmake_configure_args "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
if(ANDROID)
if(DEFINED ANDROID_ABI)
list(APPEND cmake_configure_args "-DANDROID_ABI=${ANDROID_ABI}")
endif()
if(DEFINED ANDROID_CPP_FEATURES)
list(APPEND cmake_configure_args "-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}")
endif()
if(DEFINED ANDROID_FUNCTION_LEVEL_LINKING)
list(APPEND cmake_configure_args "-DANDROID_FUNCTION_LEVEL_LINKING=${ANDROID_FUNCTION_LEVEL_LINKING}")
endif()
if(DEFINED ANDROID_NATIVE_API_LEVEL)
list(APPEND cmake_configure_args "-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}")
endif()
if(DEFINED ANDROID_NDK)
list(APPEND cmake_configure_args "-DANDROID_NDK=${ANDROID_NDK}")
endif()
if(DEFINED ANDROID_STL)
list(APPEND cmake_configure_args "-DANDROID_STL=${ANDROID_STL}")
endif()
if(DEFINED ANDROID_TOOLCHAIN_NAME)
list(APPEND cmake_configure_args "-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME}")
endif()
endif()
else()
list(APPEND cmake_configure_args "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
endif()
set(fluent_bit_external_project_dir ${CMAKE_CURRENT_BINARY_DIR}/fluent_bit)
include(ExternalProject)
set(fluent_bit_version "fix-2.1.3")
# message(${CMAKE_CURRENT_LIST_DIR})
ExternalProject_Add(fluent_bit_src
GIT_REPOSITORY https://github.com/minipada/fluent-bit
GIT_TAG ${fluent_bit_version}
GIT_CONFIG advice.detachedHead=false
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/mpack.patch
# Suppress git update due to https://gitlab.kitware.com/cmake/cmake/-/issues/16419
UPDATE_COMMAND ""
TIMEOUT 6000
BUILD_IN_SOURCE On
${cmake_commands}
CMAKE_ARGS
-DBUILD_TESTING=Off
-DCMAKE_INSTALL_PREFIX=${fluent_bit_external_project_dir}/install/
-DCMAKE_INSTALL_LIBDIR=lib/
-DFLB_EXAMPLES=Off
-DFLB_OUT_PGSQL=On
-DFLB_SHARED_LIB=On
-DFLB_PROXY_GO=On
-DSYSTEMD_UNITDIR=${fluent_bit_external_project_dir}/install/system
${cmake_configure_args}
)
externalproject_get_property(fluent_bit_src INSTALL_DIR)
set(fluent_bit_INCLUDE_DIR "${INSTALL_DIR}/../fluent_bit/install/include/")
set(fluent_bit_LIB_DIR "${INSTALL_DIR}/../fluent_bit/install/lib/fluent-bit")
set(FB_SRC_LIB_INCLUDE_DIR "${INSTALL_DIR}/src/fluent_bit_src/lib")
set(FB_SRC_INCLUDE_DIR "${INSTALL_DIR}/src/fluent_bit_src/include/fluent-bit")
set(ares_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/c-ares-1.19.0/include/")
set(cfl_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/cfl/include/cfl/")
set(config_format_INCLUDE_DIR "${FB_SRC_INCLUDE_DIR}/config_format/")
set(cmetrics_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/cmetrics/include/cmetrics/")
set(ctraces_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/ctraces/include/ctraces/")
set(jsmn_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/jsmn/")
set(mkcore_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/monkey/include/monkey/mk_core/")
set(mpack_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/mpack-amalgamation-1.1/src/mpack/")
set(msgpack_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/msgpack-c/include/msgpack/")
set(prometheus_remote_write_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/cmetrics/include/prometheus_remote_write/")
set(xxhash_INCLUDE_DIR "${FB_SRC_LIB_INCLUDE_DIR}/cfl/lib/xxhash/")
install(
DIRECTORY
${fluent_bit_INCLUDE_DIR}
${ares_INCLUDE_DIR}
DESTINATION
include
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${cfl_INCLUDE_DIR}
DESTINATION
include/cfl
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${config_format_INCLUDE_DIR}
DESTINATION
include/config_format
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${cmetrics_INCLUDE_DIR}
DESTINATION
include/cmetrics
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${ctraces_INCLUDE_DIR}
DESTINATION
include/ctraces
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${jsmn_INCLUDE_DIR}
DESTINATION
include/jsmn
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${mkcore_INCLUDE_DIR}
DESTINATION
include/mk_core
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${mpack_INCLUDE_DIR}
DESTINATION
include/mpack
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${msgpack_INCLUDE_DIR}
DESTINATION
include/msgpack
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${prometheus_remote_write_INCLUDE_DIR}
DESTINATION
include/prometheus_remote_write
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${xxhash_INCLUDE_DIR}
DESTINATION
include
USE_SOURCE_PERMISSIONS
)
install(
FILES
${fluent_bit_LIB_DIR}/libfluent-bit.so
DESTINATION
lib
)
install(
FILES
${INSTALL_DIR}/src/fluent_bit_src/library/libmsgpack-c-static.a
DESTINATION
lib
)
install(
FILES
${INSTALL_DIR}/src/fluent_bit_src/library/libfluent-bit.a
DESTINATION
lib
)
install(
DIRECTORY
cmake
DESTINATION
share/${PROJECT_NAME}
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY
${INSTALL_DIR}/src/fluent_bit_src/cmake
DESTINATION
share/${PROJECT_NAME}
USE_SOURCE_PERMISSIONS
)
ament_export_include_directories(include)
ament_export_libraries(libfluent-bit.so fluent-bit)
ament_package(CONFIG_EXTRAS fluentbit_vendor-extras.cmake)