forked from bitbouncer/kspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
336 lines (267 loc) · 9.82 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
cmake_minimum_required(VERSION 3.5)
project(kspp)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
#FEATURES
option(ENABLE_ROCKSDB "enable rocksdb support" ON)
option(ENABLE_ZK "enable zk support" OFF)
option(ENABLE_POSTGRES "enable postgres support" ON)
option(ENABLE_INFLUXDB "enable influxdb support" ON)
option(ENABLE_TDS "enable tds support" ON)
option(ENABLE_ELASTICSEARCH "enable elastic search support" ON)
option(ENABLE_S3 "enable S3 support" ON)
option(ENABLE_KINESIS "enable KINESIS support" OFF)
option(ENABLE_MQTT "enable MQTT support" OFF)
option(ENABLE_GRPC "enable grpc support" OFF)
#option(ENABLE_BITBOUNCER_STREAMING "enable bitbouncer streaming support" OFF)
option(BUILD_TOOLS "build tools" ON)
option(BUILD_SAMPLES "build examples" ON)
option(BUILD_SHARED_LIBS "build shared libs" OFF)
option(BUILD_STATIC_LIBS "build static libs" ON)
option(BUILD_TESTS "build tests" ON)
option(LINK_SHARED "link shared" OFF)
set(KSPP_VERSION_MAJOR 1)
set(KSPP_VERSION_MINOR 0)
set(CMAKE_CXX_STANDARD 17)
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wpedantic -O2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wpedantic -Wreturn-type -g -O2")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wpedantic -Wreturn-type -g -O0")
# configure a header file to pass some of the CMake settings
# to the source code
#configure_file(
# "${PROJECT_SOURCE_DIR}/kspp_config.h.in"
# "${PROJECT_BINARY_DIR}/kspp_config.h"
#)
include_directories("${PROJECT_BINARY_DIR}")
if (ENABLE_POSTGRES)
find_package(PostgreSQL REQUIRED)
include_directories(${PostgreSQL_INCLUDE_DIRS})
endif ()
find_package(Boost COMPONENTS program_options system REQUIRED)
#it seems we cannot longer find boost 1.7.0 with cmake???
#set(BOOST_LIBS
# ${Boost_PROGRAM_OPTIONS_LIBRARY}
# ${Boost_SYSTEM_LIBRARY}
# pthread
# rt
# c
# )
set(BOOST_LIBS boost_program_options boost_iostreams boost_filesystem boost_system boost_regex z bz2 pthread rt c)
SET(CSI_INCLUDE_PATH ${Boost_INCLUDE_DIR})
find_package(absl REQUIRED)
if (ENABLE_ROCKSDB)
find_package(RocksDB REQUIRED)
SET(CSI_INCLUDE_PATH ${CSI_INCLUDE_PATH} ${ROCKSDB_INCLUDE_DIRS})
SET(ROCKSDB_LIBS ${ROCKSDB_LIBRARIES} snappy bz2 z dl)
endif ()
find_package(rapidjson REQUIRED)
find_package(AvroCPP REQUIRED)
find_package(Snappy)
if (SNAPPY_FOUND)
set(SNAPPY_PKG libsnappy)
add_definitions(-DSNAPPY_CODEC_AVAILABLE)
message("Enabled snappy codec")
else (SNAPPY_FOUND)
set(SNAPPY_PKG "")
set(SNAPPY_LIBRARIES "")
message("Disabled snappy codec. libsnappy not found.")
endif (SNAPPY_FOUND)
SET(CSI_INCLUDE_PATH
${CSI_INCLUDE_PATH}
${RAPIDJSON_INCLUDEDIR}
${AVRO_INCLUDE_DIRS}
)
# SET(AVRO_LIBS avrocpp_s curl)
SET(AVRO_LIBS ${AVRO_LIBRARIES} curl ${SNAPPY_LIBRARIES})
if (ENABLE_ZK)
SET(CSI_INCLUDE_PATH
${CSI_INCLUDE_PATH}
${CMAKE_SOURCE_DIR}/../zk/src
)
file(GLOB zk_lib_files
${CMAKE_CURRENT_SOURCE_DIR}/../zk/src/*.*
)
add_library(csi-zk STATIC ${zk_lib_files})
SET(LIBZK_LIBS csi-zk)
endif () #ZK
SET(LIBRDKAFKA_LIBS rdkafka++ rdkafka crypto ssl lz4 zstd z)
SET(PROMETHEUS_CPP_LIBS prometheus-cpp-core prometheus-cpp-push)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
add_definitions(-g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DEXTERNAL_LOCKS -DMULTITHREAD)
add_definitions(-fPIC)
add_definitions(-Wno-deprecated)
include_directories(${CSI_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/include)
link_directories(${CSI_LIBRARY_PATH})
#TARGETS
file(GLOB LIB_SRCS
src/*.cpp
src/avro/*.cpp
src/metrics/*.cpp
src/internal/*.cpp
src/internal/sources/*.cpp
src/internal/sinks/*.cpp
src/internal/serdes/*.cpp
src/internal/hash/*.cpp
src/internal/utils/*.cpp
# src/internal/grpc/*.cpp
src/utils/*.cpp
src/beta/*.cpp
IF(ENABLE_ROCKSDB)
src/internal/rocksdb/*.cpp
endif ()
#if (ENABLE_S3)
#include/features/aws/*.h
#src/features/aws/*.cpp
#endif()
# src/connect/kafka_rest/kafka_rest_source.cpp
)
file(GLOB KSPP_INCLUDE_FILES
include/kspp/*.h
include/kspp/avro/*.h
include/kspp/connect/avro_file/*.h
include/kspp/utils/*
include/kspp/utils.h
include/kspp/metrics/*.h
include/kspp/sinks/*.h
include/kspp/sources/*.h
include/kspp/codecs/*.h
include/kspp/processors/*.h
include/kspp/state_stores/*.h
include/kspp/internal/*.h
include/kspp/internal/sources/*.h
include/kspp/internal/sinks/*.h
include/kspp/internal/serdes/*.h
include/kspp/internal/hash/*.h
if (ENABLE_ROCKSDB)
include/kspp/internal/rocksdb/*.h
endif()
include/kspp/internal/grpc/*.h
include/kspp/beta/*.h
)
if (ENABLE_ROCKSDB)
add_definitions(-DKSPP_ROCKSDB)
endif()
if (ENABLE_S3)
add_definitions(-DKSPP_S3)
file(GLOB S3_LIB_SRCS
include/features/aws/*.h
src/features/aws/*.cpp)
SET(AWS_S3_LIBS aws-cpp-sdk-s3 aws-cpp-sdk-core aws-c-event-stream aws-checksums aws-c-common)
endif ()
#EXTENSIONS
IF (ENABLE_ROCKSDB)
add_definitions(-DKSPP_ROCKSDB)
file(GLOB ROCKDB_LIB_SRCS
src/internal/rocksdb/*.cpp)
ENDIF()
if (ENABLE_POSTGRES)
add_definitions(-DKSPP_POSTGRES)
file(GLOB POSTGRES_LIB_SRCS
include/connect/postgres/*.h
src/connect/postgres/*.cpp)
ENDIF ()
IF (ENABLE_TDS)
add_definitions(-DKSPP_TDS)
file(GLOB TDS_LIB_SRCS
include/connect/tds/*.h
src/connect/tds/*.cpp)
SET(TDS_LIBS sybdb)
ENDIF ()
IF (ENABLE_ELASTICSEARCH)
file(GLOB ELASTICSEARCH_LIB_SRCS
include/connect/elasticsearch/*.h
src/connect/elasticsearch/*.cpp)
ENDIF ()
IF (ENABLE_INFLUXDB)
file(GLOB INFLUXDB_LIB_SRCS
include/connect/influxdb/*.h
src/connect/influxdb/*.cpp)
ENDIF ()
if (ENABLE_KINESIS)
add_definitions(-DKSPP_KINESIS)
file(GLOB KINESIS_LIB_SRCS
include/connect/aws/*.h
src/connect/aws/*.cpp)
SET(AWS_KINESIS_LIBS aws-cpp-sdk-kinesis aws-cpp-sdk-s3 aws-cpp-sdk-core aws-c-event-stream aws-checksums aws-c-common)
endif () #ENABLE_KINESIS
if (ENABLE_MQTT)
add_definitions(-DKSPP_MQTT)
file(GLOB MQTT_LIB_SRCS
include/connect/mqtt/*.h
src/connect/mqtt/*.cpp)
SET(MQTT_LIBS paho-mqttpp3 paho-mqtt3cs)
endif ()
if (ENABLE_GRPC)
add_definitions(-DKSPP_GRPC)
find_package(Protobuf REQUIRED)
message(STATUS "Using protobuf ${protobuf_VERSION}")
find_package(GRPC REQUIRED)
SET(PROTOS ./proto/bb_streaming.proto)
set(PROTO_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${PROTOS})
# Print path to generated files
message("PROTO_SRCS = ${PROTO_SRCS}")
message("PROTO_HDRS = ${PROTO_HDRS}")
grpc_generate_cpp(GRPC_SRCS GRPC_HDRS ${PROTO_SRC_DIR} ${PROTOS})
message("GRPC_SRCS = ${GRPC_SRCS}")
message("GRPC_HDRS = ${GRPC_HDRS}")
file(GLOB BITBOUNCER_GRPC_LIB_SRCS
include/internal/grpc/*.h
src/internal/grpc/*.cpp)
if (BUILD_STATIC_LIBS)
ADD_LIBRARY(kspp_grpc_s STATIC ${PROTO_SRCS} ${GRPC_SRCS} ${BITBOUNCER_GRPC_LIB_SRCS})
INSTALL(TARGETS kspp_grpc_s
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif ()
if (BUILD_SHARED_LIBS)
ADD_LIBRARY(kspp_grpc SHARED ${PROTO_SRCS} ${GRPC_SRCS} ${BITBOUNCER_GRPC_LIB_SRCS})
INSTALL(TARGETS kspp_grpc
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif ()
file(GLOB BITBOUNCER_LIB_SRCS
include/connect/bitbouncer/*.h)
SET(BB_GRPC_LIBS_STATIC kspp_grpc_s gRPC::grpc++_reflection gRPC::grpc++ gRPC::grpc protobuf::libprotobuf)
SET(BB_GRPC_LIBS_SHARED kspp_grpc gRPC::grpc++_reflection gRPC::grpc++ gRPC::grpc protobuf::libprotobuf)
endif () #ENABLE_GRPC
if (BUILD_STATIC_LIBS)
ADD_LIBRARY(kspp_s STATIC ${LIB_SRCS} ${KSPP_INCLUDE_FILES} ${S3_LIB_SRCS} ${MQTT_LIB_SRCS} ${ROCKDB_LIB_SRCS} ${POSTGRES_LIB_SRCS} ${TDS_LIB_SRCS} ${ELASTICSEARCH_LIB_SRCS} ${INFLUXDB_LIB_SRCS} ${KINESIS_LIB_SRCS})
INSTALL(TARGETS kspp_s
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif ()
if (BUILD_SHARED_LIBS)
ADD_LIBRARY(kspp SHARED ${LIB_SRCS} ${KSPP_INCLUDE_FILES} ${S3_LIB_SRCS} ${MQTT_LIB_SRCS} ${ROCKDB_LIB_SRCS} ${POSTGRES_LIB_SRCS} ${TDS_LIB_SRCS} ${ELASTICSEARCH_LIB_SRCS} ${INFLUXDB_LIB_SRCS} ${KINESIS_LIB_SRCS})
INSTALL(TARGETS kspp
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif ()
if (ENABLE_GRPC)
SET(BB_GRPC_LIBS gRPC::grpc++_reflection gRPC::grpc++ gRPC::grpc protobuf::libprotobuf gpr upb address_sorting re2 crypto ssl)
endif()
SET(ABSEIL_LIBS absl::time absl::status absl::synchronization absl::strings absl::str_format absl::memory absl::base)
SET(EXT_LIBS ${AVRO_LIBS} ${ROCKSDB_LIBS} ${LIBRDKAFKA_LIBS} ${LIBZK_LIBS} ${PROMETHEUS_CPP_LIBS} ${BOOST_LIBS} ${PostgreSQL_LIBRARIES} ${AWS_S3_LIBS} ${MQTT_LIBS} ${AWS_KINESIS_LIBS} ${TDS_LIBS} ${BB_GRPC_LIBS} ${ABSEIL_LIBS} gflags glog stdc++fs curl z zstd pthread)
#crypto ssl
if (LINK_SHARED)
SET(ALL_LIBS ${BB_GRPC_LIBS_SHARED} kspp ${EXT_LIBS})
else()
SET(ALL_LIBS ${BB_GRPC_LIBS_STATIC} kspp_s ${EXT_LIBS})
endif()
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include)
IF (BUILD_TOOLS)
add_subdirectory(tools)
ENDIF ()
IF (BUILD_SAMPLES)
add_subdirectory(examples)
ENDIF ()
IF (BUILD_TESTS)
SET(EXECUTABLE_OUTPUT_PATH bin)
include(CTest)
enable_testing()
add_subdirectory(tests)
ENDIF ()