-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt.ORIG
440 lines (365 loc) · 14.6 KB
/
CMakeLists.txt.ORIG
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
# To use this, do the following the first time:
# % mkdir build
# % cd build
# % cmake ..
# % make (install)
#
# To build code that uses the ET system,
# % cmake .. -DBUILD_ET=1
#
# To build code that uses the ZMQ,
# % cmake .. -DBUILD_ZMQ=1
#
# To build ERSAP engine/service code, define env var ERSAP_HOME and
# % cmake .. -DBUILD_ERSAP=1
#
# These flag may be combined
#
# After doing this once can do the following to recompile
# % cd <top level evio dir>
# % cmake --build build (--target install)
#
#
# The installation will default to the CODA env variable if it's defined
# This can be overridden on command line (in build dir) with:
# % cmake -DCODA_INSTALL=<my_dir> ..
# % make install
# This file came from evio-6.0 project
cmake_minimum_required(VERSION 3.10)
project(ejfat VERSION 0.1)
# define where we put FindZeroMQ.cmake file so zmq can be found
#set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_DEBUG_POSTFIX -dbg)
# Make executables
set(MAKE_EXEC 1)
# Test code build is optional and set it to OFF by default
option(BUILD_TEST "Build test code" OFF)
# uncomment to put in debug symbols or do on command line with:
# cmake -DCMAKE_BUILD_TYPE=Debug ..
#set(CMAKE_BUILD_TYPE Debug)
# Place libs & binaries in build/lib and bin (this is not for installation)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
# Set architecture-related string for installation consistent with scons file
set(ARCH ${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR})
message(STATUS "ARCH = " ${ARCH})
# CMAKE_INSTALL_PREFIX defaults to /usr/local on unix
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
Debug Release MinSizeRel RelWithDebInfo)
endif()
if (BUILD_ERSAP AND DEFINED ENV{ERSAP_HOME})
# Provide useful default paths when $ERSAP_HOME is defined
message(STATUS "Installing into ERSAP_HOME = " $ENV{ERSAP_HOME})
set(CMAKE_INSTALL_PREFIX "$ENV{ERSAP_HOME}" CACHE PATH "" FORCE)
set(CMAKE_INSTALL_INCLUDEDIR ${ERSAP_HOME}/include)
# look in here when calling find_library, etc.
list(APPEND CMAKE_PREFIX_PATH "$ENV{ERSAP_HOME}")
elseif (DEFINED INSTALL_DIR)
message(STATUS "Installing into " ${INSTALL_DIR})
set(INSTALL_DIR_DEFINED 1)
set(CMAKE_INSTALL_PREFIX ${INSTALL_DIR}/${ARCH})
set(CMAKE_INSTALL_INCLUDEDIR ${INSTALL_DIR}/common/include)
message(STATUS "CMAKE_INSTALL_PREFIX reset to " ${CMAKE_INSTALL_PREFIX})
else()
message(STATUS "Either set env var ERSAP_HOME or specify -DINSTALL_DIR=<...> on the command line or no installation possible!")
endif()
if (NOT DEFINED CMAKE_INSTALL_PLUGINDIR)
set(CMAKE_INSTALL_PLUGINDIR plugins CACHE PATH "Ersap plugins directory (plugins)")
endif()
mark_as_advanced(CMAKE_INSTALL_PLUGINDIR)
#add_compile_options(-Wall -Wextra)
add_compile_options(-O3)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
set(EMU_EXEC_FILES
emulation/lb_emu.cc
emulation/lb_rcv.cc
emulation/lb_rcv-roc.cc
emulation/pktzr_md.cc
)
set(ET_EXEC_FILES
simulation/et_fifoProducer.c
simulation/packetBlasteeEtFifo.cc
simulation/udp_rcv_et.cc
simulation/ersap_et_consumer.cc
ersap_engine/ejfat/legacy/src/main/cpp/ejfat_assemble_et_engine.cpp
)
set(DIS_EXEC_FILES
simulation/scatter.cc
simulation/gather.cc
simulation/testBufSupply.cc
simulation/packetBlasteeBuf.cc
simulation/packetBlasteeFast.cc
simulation/packetBlasterFat.cc
simulation/packetBlasteeFat.cc
simulation/packetBlasteeTcpMT.cc
)
set(UTIL_FILES
util/ByteOrder.cpp
util/ByteBuffer.cpp
util/BufferSupplyItem.cpp
util/BufferSupply.cpp
)
set(SIM_EXEC_FILES
simulation/udp_rcv_order.cc
simulation/udp_send_order.cc
simulation/packetBlastee.cc
simulation/packetBlasteeTcp.cc
simulation/packetBlaster.cc
simulation/packetBlasterSmall.cc
simulation/packetBlastee2.cc
simulation/packetBlaster2.cc
simulation/packetBlasterFat2.cc
)
set(ZMQ_EXEC_FILES
simulation/packetBlasteeZmq.cc
simulation/bufferReceiverZmq.cc
)
set(CLAS_EXEC_FILES
clas_source/clasBlaster.cc
)
set(TEST_FILES
)
set(CPP_HEADER_FILES
simulation/ejfat_packetize.hpp
simulation/ejfat_assemble_ersap.hpp
simulation/ejfat_assemble_ersap_et.hpp
util/ByteOrder.h
util/ByteBuffer.h
util/BufferSupplyItem.h
util/BufferSupply.h
)
# Files using Disruptor code also need util files, so keep them separate from other executables,
# ie don't include DIS_EXEC_FILES here
set(EXEC_FILES ${EMU_EXEC_FILES} ${SIM_EXEC_FILES})
# Disruptor build is optional and set it to OFF by default
option(BUILD_DIS "Build Disruptor-related code" OFF)
if (BUILD_DIS)
# Finding ET libs and includes involve looking at CODA install directory
if (DEFINED ENV{CODA})
message(STATUS "CODA = " $ENV{CODA})
else()
message(FATAL_ERROR "Set the \"CODA\" env var so that Disruptor libs and includes can be found!")
endif()
find_package(DISRUPTOR)
if (DISRUPTOR_FOUND)
message(STATUS "Disruptor include dir = " ${DISRUPTOR_INCLUDE_DIRS})
# Need boost libs for disruptor
find_package(Boost REQUIRED system thread chrono)
if (Boost_FOUND)
message(STATUS "Boost Found: libs = " ${Boost_LIBRARIES} ", include dirs = " ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
else()
message(FATAL_ERROR "Boost cannot be found, cmake will exit." )
endif()
else()
message(STATUS "Disruptor cannot be found, compile without it")
endif()
else()
message(STATUS "Compile without Disruptor")
endif()
# ET build is optional and set it to OFF by default
option(BUILD_ET "Build ET-related code" OFF)
if (BUILD_ET)
# Finding ET libs and includes involve looking at CODA install directory
if (DEFINED ENV{CODA})
message(STATUS "CODA = " $ENV{CODA})
else()
message(FATAL_ERROR "Set the \"CODA\" env var so that ET libs and includes can be found!")
endif()
find_package(ET)
if (ET_FOUND)
set(EXEC_FILES ${EXEC_FILES} ${ET_EXEC_FILES})
else()
message(STATUS "Et cannot be found, compile without it")
endif()
else()
message(STATUS "Compile without zeromq")
endif()
# Ersap build is optional and set it to OFF by default
option(BUILD_ERSAP "Build ERSAP engine and service" OFF)
if (BUILD_ERSAP AND DEFINED ENV{ERSAP_HOME})
find_package(Ersap REQUIRED)
add_subdirectory(ersap_engine/ejfat/legacy/src/main/cpp)
add_subdirectory(ersap_engine/ejfat/services/src/main/cpp)
endif()
# Zeromq build is optional and set it to OFF by default
option(BUILD_ZMQ "Build ZMQ-related code" OFF)
# if you tell cmake to have code use USE_ZMQ preprocessor macro
if (BUILD_ZMQ)
find_package(ZeroMQ)
if (ZeroMQ_FOUND)
#add_compile_definitions(BUILD_ZMQ)
set(EXEC_FILES ${EXEC_FILES} ${ZMQ_EXEC_FILES})
else()
message(STATUS "Zeromq cannot be found, compile without it")
endif()
else()
message(STATUS "Compile without zeromq")
endif()
# CLAS12 source build is optional and set it to OFF by default
option(BUILD_CLAS "Build CLAS 12 source code" OFF)
# if you tell cmake to have code use USE_CLAS preprocessor macro
if (BUILD_CLAS)
find_package(HIPO)
if (HIPO_FOUND)
set(EXEC_FILES ${EXEC_FILES} ${CLAS_EXEC_FILES})
else()
message(STATUS "Hipo cannot be found, compile without it")
endif()
else()
message(STATUS "Compile without hipo")
endif()
if (BUILD_TEST)
set(EXEC_FILES ${EXEC_FILES} ${TEST_FILES})
endif()
#include(FindPackageHandleStandardArgs)
#
#find_package(Doxygen)
#
#if( DOXYGEN_FOUND )
# message(STATUS "Doxygen found")
#
# # Change these values from cmake defaults in the Doxyfile
# set(DOXYGEN_GENERATE_TREEVIEW YES)
# set(DOXYGEN_REFERENCED_BY_RELATION YES)
# set(DOXYGEN_EXCLUDE_PATTERNS */.* */CMakeFiles/* */_CPack_Packages/* CMakeLists.txt CMakeCache.txt)
# #set(DOXYGEN_EXCLUDE src/libsrc++/pugixml.cpp src/libsrc++/pugixml.hpp)
# set(DOXYGEN_FILE_PATTERNS *.c *.cpp *.h)
# #set(DOXYGEN_WARN_LOGFILE doxyerrors.log)
# set(DOXYGEN_SORT_MEMBERS_CTORS_1ST YES)
# set(DOXYGEN_SHOW_GROUPED_MEMB_INC YES)
# set(DOXYGEN_INLINE_IHERITED_MEMB YES)
# set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
#
# # Add target of "docCC"
# #set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/CC)
# #doxygen_add_docs(docCC src/libsrc++)
#
# # Change these values from cmake defaults in the Doxyfile
# set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
# set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/C)
#
# # Add target of "docC"
# doxygen_add_docs(docC src/libsrc src/execsrc)
#
#elseif(NOT DEFINED C_ONLY)
# message(FATAL_ERROR "Doxygen NOT found, cmake will exit." )
#endif()
# Shared evio C library
#add_library(evio SHARED ${C_LIB_FILES})
#set_target_properties(evio PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
#include_directories(evio PUBLIC src/libsrc /usr/local/include)
#if (NOT DEFINED C_ONLY)
# # Shared evio C++ library
# add_library(eviocc SHARED ${CPP_LIB_FILES})
# set_target_properties(eviocc PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
# target_link_libraries(eviocc ${LZ4_LIBRARY} ${Boost_LIBRARIES} ${DISRUPTOR_LIBRARY})
# include_directories(eviocc PUBLIC src/libsrc++ /usr/local/include
# ${Boost_INCLUDE_DIRS} ${LZ4_INCLUDE_DIRS} ${DISRUPTOR_INCLUDE_DIR})
#
# if (DEFINED MAKE_EXAMPLES)
# foreach(fileName ${TEST})
# # Get file name with no directory or extension as executable name
# get_filename_component(execName ${fileName} NAME_WE)
# # Create executable from file
# add_executable(${execName} ${fileName})
# # Put debug extension on if applicable
# set_target_properties(${execName} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
# # Needs these libs
# target_link_libraries(${execName} eviocc pthread ${Boost_LIBRARIES} ${LZ4_LIBRARY} expat dl z m )
#
# # Only install if installation directory has been defined
# if (DEFINED INSTALL_DIR_DEFINED)
# # Install into bin/testC dir
# install(TARGETS ${execName} RUNTIME DESTINATION bin/test)
# endif()
# endforeach(fileName)
# endif()
#else()
# message(STATUS "NOT compiling C++ evio library!!!" )
#endif()
# Test programs
if (DEFINED MAKE_EXEC)
foreach(fileName ${EXEC_FILES})
# Get file name with no directory or extension as executable name
get_filename_component(execName ${fileName} NAME_WE)
# Create executable from file
message(STATUS "Create normal executable " ${execName})
add_executable(${execName} ${fileName})
# Put debug extension on if applicable
set_target_properties(${execName} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
# Location of include files
target_include_directories(${execName} PUBLIC ${HIPO_INCLUDE_DIRS}
${ZeroMQ_INCLUDE_DIRS}
${ET_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/simulation
${CMAKE_SOURCE_DIR}/util)
# Needs these libs
target_link_libraries(${execName} pthread ${ZeroMQ_LIBRARIES} ${ET_LIBRARY} ${HIPO_LIBRARIES})
# Only install if installation directory has been defined
if (DEFINED INSTALL_DIR_DEFINED)
# Install into bin dir
install(TARGETS ${execName} RUNTIME DESTINATION bin)
endif()
endforeach(fileName)
if (DISRUPTOR_FOUND)
message(STATUS "TRY DISRUPTOR CODE:")
# This files need util files added to executable
foreach(fileName ${DIS_EXEC_FILES})
# Get file name with no directory or extension as executable name
get_filename_component(execName ${fileName} NAME_WE)
# Create executable from file
message(STATUS "Create disruptor-related executable " ${execName})
add_executable(${execName} ${fileName} ${UTIL_FILES})
# Put debug extension on if applicable
set_target_properties(${execName} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
# Location of include files
target_include_directories(${execName} PUBLIC ${CMAKE_SOURCE_DIR}/simulation
${CMAKE_SOURCE_DIR}/util
${ZeroMQ_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${DISRUPTOR_INCLUDE_DIRS}
${ET_INCLUDE_DIRS})
# Needs these libs
target_link_libraries(${execName} pthread ${Boost_LIBRARIES} ${ZeroMQ_LIBRARIES} ${DISRUPTOR_LIBRARY} ${ET_LIBRARY})
# Only install if installation directory has been defined
if (DEFINED INSTALL_DIR_DEFINED)
# Install into bin dir
install(TARGETS ${execName} RUNTIME DESTINATION bin)
endif()
endforeach(fileName)
endif()
endif()
# Only install if installation directory has been defined
if (DEFINED INSTALL_DIR_DEFINED)
install(FILES ${CPP_HEADER_FILES} DESTINATION include)
install(FILES ${CPP_HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
## Only install if installation directory has been defined
#if (DEFINED INSTALL_DIR_DEFINED)
# # Installation defaulting to ${CMAKE_INSTALL_PREFIX}/lib or include
# install(TARGETS evio LIBRARY DESTINATION lib)
# install(FILES ${C_HEADER_FILES} DESTINATION include)
#
# if (NOT DEFINED C_ONLY)
# install(TARGETS eviocc LIBRARY DESTINATION lib)
# install(FILES ${CPP_HEADER_FILES} DESTINATION include)
# install(FILES ${CPP_HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# endif()
#endif()
## Uninstall target
#if(NOT TARGET uninstall)
# configure_file(
# "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
# "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
#
# add_custom_target(uninstall
# COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
#endif()
#