CMakeLists.txt 11.2 KB
Newer Older
1
cmake_minimum_required(VERSION 3.2)
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
2
3
4
5
6
project (pipefabric)

set(CMAKE_MACOSX_RPATH 1)

set (PipeFabric_VERSION_MAJOR 0)
7
set (PipeFabric_VERSION_MINOR 2)
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
8

9
include(CTest)
10

11
12
13
################################################################################
# customization section                                                        #
################################################################################
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
14

15
16
17
# Installation path
set(PIPEFABRIC_DIR "/usr/local/pfabric")

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
18
# The following variables enable or disable additional functionalities,
19
20
# which can be switched off to reduce build time.

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
21
# Support Matrix Operations (needs Eigen library to be installed)
22
23
24
25
option(SUPPORT_MATRICES
  "support matrix operations as tuple and state type"
  OFF
)
26

27
28
# Build use cases
option(BUILD_USE_CASES
29
30
31
32
  "build use cases to show functionality examples"
  OFF
)

33
34
35
# Use RabbitMQ as network source
option(USE_RABBITMQ
  "use RabbitMQ as network source"
Constantin Pohl's avatar
Constantin Pohl committed
36
  OFF
37
38
39
40
)
# Use Apache Kafka as network source
option(USE_KAFKA
  "use Apache Kafka as network source"
Constantin Pohl's avatar
Constantin Pohl committed
41
  OFF
Constantin Pohl's avatar
Constantin Pohl committed
42
43
44
45
)
# Use MQTT as network source
option(USE_MQTT
  "use MQTT as network source"
Constantin Pohl's avatar
Constantin Pohl committed
46
  OFF
47
)
48

49
# Use the boost::spirit parser for converting strings to numbers
50
option(USE_BOOST_SPIRIT_PARSER
51
52
  "use the boost::spirit::qi parsers for converting strings to tuple attributes"
  ON
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
53
54
)

55
# Use RocksDB key-value store for implementing tables
56
# If switched to off, it will not be downloaded, saving initial building time.
57
58
option(USE_ROCKSDB_TABLE
  "use RocksDB for implementing persistent tables"
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
59
  ON
60
61
)

62
63
64
65
66
67
68
69
70
71
72
73
# Build only pipefabric libraries (cep and core)
# If switched to on, no other components (like RestDemo, QueryCompiler,...) will be built.
# Building test cases is independent from this.
option(BUILD_ONLY_LIBS
  "build only the two pipefabric libraries"
  OFF
)

# Build test cases for pipefabric functionality
# If switched to off, no tests will be build
option(BUILD_TEST_CASES
  "build tests for pipefabric functionality"
74
  ON
75
76
)

Constantin Pohl's avatar
Constantin Pohl committed
77
78
79
#Build google benchmark library
option(BUILD_GOOGLE_BENCH
  "build google benchmark"
80
  ON
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
81
82
)

Constantin Pohl's avatar
Constantin Pohl committed
83
84
85
# Build benchmark test
option(BUILD_BENCHMARKS
  "build benchmarks for pipefabric"
86
87
88
  ON
)

89
90
91
92
93
94
################################
# End of customization section #
################################

# Use cases require matrix support (image and graph processing)
if(BUILD_USE_CASES)
95
	set(SUPPORT_MATRICES ON)
96
97
endif()

Constantin Pohl's avatar
Constantin Pohl committed
98
99
100
101
102
# Benchmark test requires benchmark library
if (BUILD_BENCHMARKS)
  set(BUILD_GOOGLE_BENCH ON)
endif()

103
104
105
106
107
# Force using intel compiler
#include(CMakeForceCompiler)
#CMAKE_FORCE_C_COMPILER(icc "Intel C Compiler")
#CMAKE_FORCE_CXX_COMPILER(icpc "Intel C++ Compiler")

108
# C++ compiler flags
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
109
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-deprecated -g -O1 -Wsign-compare")
110
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
111
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs -Wno-#pragma-messages")
112
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
113
114
115
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -Wno-unused")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd488 -wd597")
116
117
endif()

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
118
119
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused -Wno-uninitialized")

120
121
122
# Add our CMake directory to CMake's module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/")

123
# We download some 3rdparty modules from github.com before building the project.
124
125
include(Download3rdParty)

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
126
127
128
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
129
130
131
set(DYLIB_LIBRARY "-ldl")
else()
set(DYLIB_LIBRARY "")
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
132
133
endif()

134
135
136
##############################
# memory allocator libraries #
##############################
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
137
138
139
140
141
142
143
144
145
146
147
148
149
#
find_package(JeMalloc)
find_package(Tcmalloc)
if (Tcmalloc_FOUND)
     message(STATUS "using the tcmalloc allocator")
	 set(MALLOC_LIB ${Tcmalloc_LIBRARIES})
elseif(JEMALLOC_FOUND)
	  message(STATUS "using the jemalloc allocator")
	 set(MALLOC_LIB ${JEMALLOC_LIBRARIES})
else()
     set(MALLOC_LIB "")
endif()

150
151
152
153
154
155
156
157
158
159
160
########################
# Google benchmark library
########################
#
if (BUILD_GOOGLE_BENCH)
  include_directories("${THIRD_PARTY_DIR}/benchmark/include")
  set (BENCHMARK_LIB "${THIRD_PARTY_DIR}/benchmark/lib/libbenchmark.a")
else()
  set (BENCHMARK_LIB "")
endif()

161
########################
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
162
# RocksDB database library
163
164
########################
#
165
166
167
168
169
170
if (USE_ROCKSDB_TABLE)
  message(STATUS "using RocksDB key-value store")
  add_definitions(-DUSE_ROCKSDB_TABLE)
  set (ROCKSDB_LIB "${THIRD_PARTY_DIR}/rocksdb/lib/librocksdb.a")
  include_directories("${THIRD_PARTY_DIR}/rocksdb/include")

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
171
  find_package( BZip2 )
172
173
174
175
176
  if ( BZIP2_FOUND )
    #  include_directories( ${BZIP2_INCLUDE_DIRS} )
    set (ROCKSDB_LIB ${ROCKSDB_LIB} ${BZIP2_LIBRARIES})
  endif( BZIP2_FOUND )

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
177
  find_package( ZLIB )
178
179
180
181
  if ( ZLIB_FOUND )
    #  include_directories( ${BZIP2_INCLUDE_DIRS} )
    set (ROCKSDB_LIB ${ROCKSDB_LIB} ${ZLIB_LIBRARIES})
  endif( ZLIB_FOUND )
182
else()
183
184
  message(STATUS "don't use RocksDB key-value store")
  set (ROCKSDB_LIB "")
185
186
endif()

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
187
188
189
190
######################
# Boost C++ library
######################
#
191
SET(BOOST_MIN_VERSION "1.60.0")
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
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
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS
    program_options
    system
    coroutine
    iostreams
    log
    filesystem
    timer
    serialization
    thread
    regex
    chrono
    date_time
)
if (NOT Boost_FOUND)
     message(FATAL_ERROR "Fatal error: Boost (version >= ${BOOST_MIN_VERSION}) required.\n"
 )
endif (NOT Boost_FOUND)

if (Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIR})
    add_definitions( "-DHAS_BOOST" )
    add_definitions( "-DBOOST_LOG_DYN_LINK" )
    if(USE_BOOST_SPIRIT_PARSER)
        add_definitions( "-DUSE_BOOST_SPIRIT_PARSER" )
    endif()
endif()

set(BOOST_LIBRARIES
		${Boost_DATE_TIME_LIBRARY}
		${Boost_LOG_LIBRARY}
		${Boost_COROUTINE_LIBRARY}
		${Boost_IOSTREAMS_LIBRARY}
225
        ${Boost_FILESYSTEM_LIBRARY}
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
226
227
228
229
230
		${Boost_SYSTEM_LIBRARY}
		${Boost_CHRONO_LIBRARY}
		${Boost_TIMER_LIBRARY}
		${Boost_THREAD_LIBRARY}
		${Boost_REGEX_LIBRARY}
231
	    ${DYLIB_LIBRARY}
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
)

######################
# ZeroMQ library
######################
#
#
find_package(ZeroMQ)
if (ZEROMQ_FOUND)
    add_definitions( "-DHAS_ZMQ" )
    include_directories(${ZEROMQ_INCLUDE_DIR})
    link_directories(${ZEROMQ_LIBRARY_DIR})
endif(ZEROMQ_FOUND)

246
247
248
249
250
251
252
253
254
255
256
257

#-----------------------------------------------------------------------------------------
#
# Matrix Support
#

if(SUPPORT_MATRICES)
	####################################
	# Eigen library for linear algebra #
	####################################
	find_package(Eigen3)
 	if(EIGEN3_FOUND)
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
258
	  message(STATUS "using Eigen3 library for linear algebra")
259
260
261
262
263
264
265
		include_directories(${EIGEN3_INCLUDE_DIR})
	else()
		message(STATUS "Eigen3 not found")
	endif()
	add_definitions(-DSUPPORT_MATRICES)
endif()

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
266
267
268
269
270
271
272
#-----------------------------------------------------------------------------------------
#
# Building PipeFabric core library
#

include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/pubsub")
273
274
275

# because we have downloaded external projects into build we have to add them here
include_directories("${THIRD_PARTY_DIR}")
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
276
277
278
279
280
281
282
283
284

if (ZEROMQ_FOUND)
set (ZEROMQ_SOURCES
  net/ZMQSocket.cpp
  qop/ZMQSource.cpp)
else()
set (ZEROMQ_SOURCES "")
endif (ZEROMQ_FOUND)

285
set(core_sources
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
286
287
288
289
290
291
  core/TimestampHelper.cpp
  core/Punctuation.cpp
  qop/TextFileSource.cpp
  qop/RESTSource.cpp
  qop/Window.cpp
  qop/TriggerNotifier.cpp
292
293
294
  dsl/Topology.cpp
  dsl/Dataflow.cpp
  dsl/PFabricContext.cpp
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
295
  table/TableInfo.cpp
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
296
  ${ZEROMQ_SOURCES}
297
298
299
300
  # we need this as dependency to download the sources from github
  ${THIRD_PARTY_DIR}/json
  ${THIRD_PARTY_DIR}/fmt
  ${THIRD_PARTY_DIR}/SimpleWeb
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
301
  ${THIRD_PARTY_DIR}/catch
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
302
303
)

304
305
306
307
308
309
310
if(USE_ROCKSDB_TABLE)
  set(core_sources
    ${core_sources}
    ${THIRD_PARTY_DIR}/rocksdb
  )
endif()

311
312
313
314
315
316
317
if(BUILD_GOOGLE_BENCH)
  set(core_sources
    ${core_sources}
    ${THIRD_PARTY_DIR}/benchmark
  )
endif()

318
319
320
321
322
set(core_libs
  ${BOOST_LIBRARIES}
  ${ZEROMQ_LIBRARIES}
)

323
324
325
326
327
328
329
330
331
#-----------------------------------------------------------------------------------------
#
##########
# RabbitMQ
##########
#
#
if(USE_RABBITMQ)
  add_definitions(-DUSE_RABBITMQ)
332
333
334
335
336
337
338
339
340
341
  set(core_libs
    ${core_libs}
    amqpcpp
    rabbitmq
  )
  set(core_sources
    ${core_sources}
    net/RabbitMQSource.cpp
  )
endif()
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#-----------------------------------------------------------------------------------------
#
##############
# Apache Kafka
##############
#
#
if(USE_KAFKA)
  add_definitions(-DUSE_KAFKA)
  set(core_libs
    ${core_libs}
    cppkafka
    rdkafka
  )
  set(core_sources
    ${core_sources}
    net/KafkaSource.cpp
  )
endif()
#-----------------------------------------------------------------------------------------
Constantin Pohl's avatar
Constantin Pohl committed
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#
######
# MQTT
######
#
#
if(USE_MQTT)
  add_definitions(-DUSE_MQTT)
  set(core_libs
    ${core_libs}
    paho-mqtt3c
    paho-mqtt3cs
    paho-mqtt3a
    paho-mqtt3as
    paho-mqttpp3
  )
  set(core_sources
    ${core_sources}
    net/MQTTSource.cpp
  )
endif()
#-----------------------------------------------------------------------------------------
384

385
386
387
add_library(pfabric_core SHARED
  ${core_sources}
)
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
388
389

target_link_libraries(pfabric_core
390
  ${core_libs}
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
391
392
393
394
395
396
397
398
)

#-----------------------------------------------------------------------------------------
#
# Building PipeFabric CEP library
#
add_library(pfabric_cep SHARED
                  cep/Matcher.cpp
399
400
                  # we need this as dependency to download the sources from github
                  ${THIRD_PARTY_DIR}/fmt
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
401
402
403
404
405
406
)

target_link_libraries(pfabric_cep
                ${BOOST_LIBRARIES}
)

407
408
409
410
411
412
413
414
415
416
417
418
#-----------------------------------------------------------------------------------------
#
# Experimental SQL query compiler
#
add_subdirectory(qcomp)

#-----------------------------------------------------------------------------------------
#
# Demo project
#
add_subdirectory(demo)

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
419
420
421
422
423
424
425
426
427
428
#-----------------------------------------------------------------------------------------
#
# Unit tests using Catch
#
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE test)

enable_testing()
add_subdirectory(test)

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
429
430
431
432
433
#-----------------------------------------------------------------------------------------
#
# Micro-benchmarking using Google Benchmark
#
add_subdirectory(bench)
Constantin Pohl's avatar
Constantin Pohl committed
434
435
436
437
438
439

#-----------------------------------------------------------------------------------------
#
# Build use cases
#
if(BUILD_USE_CASES)
440
441
442
443
444
	#######################################
	# OpenCV library for image processing #
	#######################################
	find_package(OpenCV REQUIRED)
	if(OpenCV_FOUND)
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
445
446
	 message(STATUS "using OpenCV library for image processing")
	 include_directories(${OpenCV_INCLUDE_DIR})
447
	else()
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
448
		message(STATUS "OpenCV not found")
449
	endif()
Constantin Pohl's avatar
Constantin Pohl committed
450
endif()
451
  add_subdirectory(usecases)
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
452
#-----------------------------------------------------------------------------------------
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#
# Installation
#
set(PIPEFABRIC_LIBS pfabric_core pfabric_cep)
set(PIPEFABRIC_LIB_DIR "${PIPEFABRIC_DIR}/lib")
set(PIPEFABRIC_INCLUDE_DIR "${PIPEFABRIC_DIR}/include")

foreach(LIB ${PIPEFABRIC_LIBS})
install(TARGETS ${LIB} DESTINATION ${PIPEFABRIC_LIB_DIR})
endforeach(LIB)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
   DESTINATION ${PIPEFABRIC_INCLUDE_DIR}
   FILES_MATCHING
   PATTERN "*.hpp"
   PATTERN "*.h"
)
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
470

471
472
# show used compiler
message("Using Compiler: ${CMAKE_CXX_COMPILER_ID}.")