-
Notifications
You must be signed in to change notification settings - Fork 71
/
CMakeLists.txt
385 lines (328 loc) · 12.9 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
###########################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2017
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# Contact: lima@esrf.fr
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
cmake_minimum_required(VERSION 3.6)
project (Lima)
include(cmake/project_version.cmake)
set(NAME "core")
# Include additional modules that are used unconditionally
include(GNUInstallDirs)
include(GenerateExportHeader)
# If conda build, always set lib dir to 'lib'
if($ENV{CONDA_BUILD})
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
# Set lower / upper case project names
string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPER)
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
# Set targets export name (used by lima and dependencies)
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWER}-targets")
#set(namespace "${PROJECT_NAME}::")
# Enable C++11 and later
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC AND MSVC_VERSION GREATER 1500)
add_compile_definitions(NOMINMAX)
endif()
# CMake additional macros
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(LimaTools)
if(UNIX AND LIMA_ENABLE_NUMA)
# Numa is needed for advanced buffer management
find_package(Numa REQUIRED)
endif()
# Import pthread
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
### Define options
include(Options.cmake)
### Find dependencies
# Processlib third-party is mandatory
if (LIMA_BUILD_SUBMODULES)
add_subdirectory(third-party/Processlib)
else()
find_package(Processlib REQUIRED)
endif()
# Enable python binding code compilation using sip generator
if(LIMA_ENABLE_PYTHON)
limatools_find_python_and_sip()
endif()
#--------------------------------------------------------------------------------
# Define source files
#--------------------------------------------------------------------------------
# add_subdirectory(common)
# add_subdirectory(control)
# add_subdirectory(control/software_operation)
# add_subdirectory(hardware)
set(common_srcs
common/src/Constants.cpp
common/src/SizeUtils.cpp
common/src/Timestamp.cpp
common/src/ThreadUtils.cpp
common/src/Exceptions.cpp
common/src/MemUtils.cpp
common/src/RegExUtils.cpp
common/src/BufferHelper.cpp
common/src/AcqState.cpp
common/src/Debug.cpp
common/src/VideoUtils.cpp
common/src/Event.cpp
common/src/Timer.cpp
common/src/AppPars.cpp
common/src/DirectoryEventUtils.cpp)
if(UNIX)
list(APPEND common_srcs
common/src/SimplePipe.cpp
)
endif()
file(GLOB_RECURSE common_incs "common/include/*.h")
set(hardware_srcs
hardware/src/HwInterface.cpp
hardware/src/HwCap.cpp
hardware/src/HwSyncCtrlObj.cpp
hardware/src/HwFrameInfo.cpp
hardware/src/HwFrameCallback.cpp
hardware/src/HwBufferCtrlObj.cpp
hardware/src/HwBufferMgr.cpp
hardware/src/HwShutterCtrlObj.cpp
hardware/src/HwMaxImageSizeCallback.cpp
hardware/src/HwDetInfoCtrlObj.cpp
hardware/src/HwBinCtrlObj.cpp
hardware/src/HwRoiCtrlObj.cpp
hardware/src/HwFlipCtrlObj.cpp
hardware/src/HwSerialLine.cpp
hardware/src/HwBufferSave.cpp
hardware/src/HwVideoCtrlObj.cpp
hardware/src/HwEventCtrlObj.cpp
hardware/src/HwSavingCtrlObj.cpp
hardware/src/HwReconstructionCtrlObj.cpp
hardware/src/HwTestApp.cpp
)
if(UNIX)
list(APPEND hardware_srcs hardware/src/HwFileEventMgr.cpp)
endif()
file(GLOB_RECURSE hardware_incs "hardware/include/*.h")
set(control_srcs
control/src/CtSaving.cpp
control/src/CtControl.cpp
control/src/CtAcquisition.cpp
control/src/CtBuffer.cpp
control/src/CtImage.cpp
control/src/CtSaving_ZBuffer.cpp
control/src/CtSaving_Compression.cpp
control/src/CtSaving_Edf.cpp
control/src/CtShutter.cpp
control/src/CtAccumulation.cpp
control/src/CtVideo.cpp
control/src/CtEvent.cpp
control/src/CtTestApp.cpp
)
file(GLOB_RECURSE control_incs "control/include/*.h")
set(software_operation_srcs
control/software_operation/src/SoftOpInternalMgr.cpp
control/software_operation/src/SoftOpExternalMgr.cpp
control/software_operation/src/SoftOpId.cpp
)
file(GLOB_RECURSE software_operation_incs "control/software_operation/include/*.h")
set(extra_libs)
set(extra_includes)
set(extra_definitions)
# Optional for libconfig++ support
if(LIMA_ENABLE_CONFIG)
find_package(Libconfig)
if(${LIBCONFIG_FOUND})
list(APPEND extra_definitions -DWITH_CONFIG)
list(APPEND extra_libs ${LIBCONFIG_LIBRARIES})
list(APPEND common_srcs common/src/ConfigUtils.cpp)
list(APPEND control_srcs control/src/CtConfig.cpp)
list(APPEND extra_includes ${LIBCONFIG_INCLUDE_DIRS})
else()
message(FATAL_ERROR "libconfig++ not found, set LIB_CONFIG path or disable LIMA_ENABLE_CONFIG")
endif()
endif()
# Option for Spec-like shared-memory (SPS) support
if(LIMA_ENABLE_SPS_IMAGE)
list(APPEND extra_definitions -DWITH_SPS_IMAGE)
list(APPEND control_srcs control/src/CtSpsImage.cpp third-party/Sps/Src/sps.c)
endif()
# Option for extra saving formats edf.gz, edf.lz4, cbf, hdf5, tiff, fits
include(Saving.cmake)
#--------------------------------------------------------------------------------
# Add the library limacore definition
#--------------------------------------------------------------------------------
add_library(limacore SHARED
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}/project_version.cc # Add version info
${common_srcs}
${hardware_srcs}
${control_srcs}
${software_operation_srcs}
${common_incs}
${hardware_incs}
${control_incs}
${software_operation_incs}
)
# Set version
set_target_properties(limacore PROPERTIES
VERSION "${PROJECT_VERSION}"
SOVERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
# Generate export macros
generate_export_header(limacore)
message("#####################################")
message("${CMAKE_BINARY_DIR}")
message("#####################################")
target_include_directories(limacore PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hardware/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/control/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/control/software_operation/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
if(LIMA_BUILD_SUBMODULES)
target_include_directories(limacore PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/core/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/tasks/include>")
endif()
if(UNIX AND LIMA_ENABLE_NUMA)
target_compile_definitions(limacore PUBLIC LIMA_USE_NUMA)
target_include_directories(limacore PRIVATE "${NUMA_INCLUDE_DIR}")
endif()
if(LIMA_ENABLE_SPS_IMAGE)
target_compile_definitions(limacore PUBLIC WITH_SPS_IMAGE)
target_include_directories(limacore PRIVATE "${CMAKE_SOURCE_DIR}/third-party/Sps/Include")
endif()
# Set LIMA_NO_DEBUG if LIMA_ENABLE_DEBUG is set
if(NOT LIMA_ENABLE_DEBUG)
target_compile_definitions(limacore PUBLIC LIMA_NO_DEBUG)
endif()
# add all include paths coming from saving format options
target_include_directories(limacore PRIVATE ${extra_includes} ${saving_includes})
# add compiler definitions required by saving libraries
target_compile_definitions(limacore PUBLIC ${extra_definitions} ${saving_definitions})
# add libraries
target_link_libraries(limacore PUBLIC Threads::Threads processlib)
target_link_libraries(limacore PRIVATE ${saving_libs} ${extra_libs})
target_link_libraries(limacore PRIVATE ${saving_private_libs})
if(UNIX)
target_compile_definitions(limacore PUBLIC -DHAS_INOTIFY)
target_link_libraries(limacore PRIVATE "rt")
if(LIMA_ENABLE_NUMA)
target_link_libraries(limacore PRIVATE ${NUMA_LIBRARY})
endif()
endif()
if(WIN32)
target_compile_definitions(limacore PRIVATE LIMACORE_EXPORTS)
set_target_properties(limacore PROPERTIES PREFIX "lib")
set_target_properties(limacore PROPERTIES IMPORT_PREFIX "lib")
endif()
#--------------------------------------------------------------------------------
# SIP generates binding code for python
#--------------------------------------------------------------------------------
if(LIMA_ENABLE_PYTHON)
set(INCLUDES)
file(GLOB SIP_SOURCES
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/common/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/common/sip/*.sip"
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/hardware/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/hardware/sip/*.sip"
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/control/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/control/sip/*.sip"
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/control/software_operation/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/control/software_operation/sip/*.sip")
foreach(SIP_SOURCES ${SIP_SOURCES})
set(INCLUDES
"${INCLUDES}
%Include ${SIP_SOURCES}"
)
endforeach()
configure_file(sip/limacore.sip.in sip/limacore.sip)
list(APPEND LIMA_SIP_INCLUDE_DIRS
"${CMAKE_CURRENT_BINARY_DIR}/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/common/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/hardware/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/control/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/control/software_operation/sip")
if (LIMA_BUILD_SUBMODULES)
list(APPEND LIMA_SIP_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/sip")
# This is required for LimaTools
list(APPEND PROCESSLIB_SIP_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/tasks/sip")
endif()
set(SIP_INCLUDE_DIRS
${LIMA_SIP_INCLUDE_DIRS}
${PROCESSLIB_SIP_INCLUDE_DIRS})
if (NOT LIMA_ENABLE_CONFIG)
set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} WITH_CONFIG)
endif()
if (NOT LIMA_ENABLE_SPS_IMAGE)
set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} WITH_SPS_IMAGE)
endif()
# set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/sip/limacore.sip PROPERTIES OBJECT_DEPENDS ${SIP_SOURCES})
# Run sip now !
add_sip_python_module(limacore ${CMAKE_CURRENT_BINARY_DIR}/sip/limacore.sip FALSE)
target_include_directories(python_module_limacore PRIVATE
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/sip
${CMAKE_CURRENT_SOURCE_DIR}/sip/core
${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/sip)
target_link_libraries(python_module_limacore PRIVATE limacore ${NUMPY_LIBRARIES})
add_custom_command(TARGET lima${NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/python/Lima ${CMAKE_BINARY_DIR}/python/Lima)
endif()
## Installation
include(Install.cmake)
#--------------------------------------------------------------------------------
# Option for openGL real-time display support
#--------------------------------------------------------------------------------
if(LIMA_ENABLE_GLDISPLAY)
add_subdirectory(third-party/gldisplay)
endif()
#--------------------------------------------------------------------------------
# TESTS, run ctest or make test
#--------------------------------------------------------------------------------
if(LIMA_ENABLE_TESTS)
enable_testing()
add_subdirectory(control/test)
add_subdirectory(common/test)
endif()
#--------------------------------------------------------------------------------
# CAMERA list is in cmake/CameraList.cmake file
#--------------------------------------------------------------------------------
if (LIMA_BUILD_SUBMODULES)
include(CameraList)
endif()
#--------------------------------------------------------------------------------
# Python Tango server
#--------------------------------------------------------------------------------
if(LIMA_ENABLE_PYTANGO_SERVER)
add_subdirectory(applications/tango/python)
endif()
#--------------------------------------------------------------------------------
# PACKAGES debian at least, run cpack or make package
#--------------------------------------------------------------------------------
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ESRF/BLISS") #required
set(CPACK_PACKAGE_CONTACT "lima@esrf.fr")
include(CPack)