-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
324 lines (267 loc) · 10.1 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
cmake_minimum_required(VERSION 2.8)
project(OpenLiveStacker)
include_directories(include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2 -g")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
option(OPENCV_ROOT "Path to OpenCV Library" "")
option(NO_SSE4 "Disable SSE 4.1/4.3 on x86/x86_64 builds" OFF)
find_library(ASI_CAMERA_LIB ASICamera2)
find_path(ASI_CAMERA_HDR ASICamera2.h)
find_library(INDI_LIB indiclient)
find_path(INDI_HEADER libindi/baseclient.h)
find_library(INDIGO_LIB indigo)
find_path(INDIGO_HEADER indigo/indigo_bus.h)
find_library(TOUPCAM_CAMERA_LIB toupcam)
find_path(TOUPCAM_CAMERA_HDR toupcam.h)
find_library(LIBTIFF tiff)
find_library(LIBCPPCMS cppcms)
find_library(LIBBOOSTER booster)
find_library(LIBUVC uvc)
find_library(LIBRAW_LIB raw_r)
find_path(LIBRAW_HDR libraw/libraw.h)
find_path(LIBCFITSIO_HDR fitsio.h)
find_library(LIBCFITSIO cfitsio)
find_path(LIBCURL_HDR curl/curl.h)
find_path(LIBZ_HDR zlib.h)
find_path(LIBCPPCMS_HRD cppcms/application.h)
find_path(LIBCAMERA2_HDR camera/NdkCameraDevice.h)
find_path(LIBMEDIANDK_HDR media/NdkImageReader.h)
find_library(LIBCURL curl)
find_library(LIBZ z)
find_library(LIBCAMERA2_LIB camera2ndk)
find_library(LIBMEDIANDK_LIB mediandk)
find_path(LIBGPHOTO2_HDR gphoto2/gphoto2.h)
find_library(LIBGPHOTO2_LIB gphoto2)
find_library(LIBGPHOTO2_PORT_LIB gphoto2_port)
set(WITH_SSE OFF)
set(OLS_EXTRA )
set(OLS_LIB_EXTRA )
include_directories(${LIBCPPCMS_HRD})
if(LIBCURL_HDR AND LIBCURL)
set(WITH_CURL ON)
add_definitions(-DWITH_CURL)
message("-- ASTAP DB Download enabled")
else()
message("-- ASTAP DB Download DISABLED")
set(WITH_CURL OFF)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(OLS_EXTRA src/android_main.cpp)
set(ANDROID_BUILD ON)
add_definitions(-DANDROID_SUPPORT)
add_definitions(-DOLS_ARCH="${ANDROID_ABI}")
find_library(LIBUSB usb1.0)
if(${ANDROID_ABI} STREQUAL "x86_64" OR ${ANDROID_ABI} STREQUAL "x86")
set(WITH_SSE ON)
if(${ANDROID_ABI} STREQUAL "x86")
set(NO_SSE4 ON)
endif()
add_definitions(-DUSE_CV_SIMD)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a") # No simd for armeabi-v7a
add_definitions(-DUSE_CV_SIMD)
add_definitions(-DUSE_ARM_SIMD)
endif()
else()
message("CPU: ${CMAKE_SYSTEM_PROCESSOR}")
add_definitions(-DOLS_ARCH="${CMAKE_SYSTEM_PROCESSOR}")
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
add_definitions(-DUSE_CV_SIMD)
set(WITH_SSE ON)
endif()
set(ANDROID_BUILD OFF)
endif()
if(WITH_SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
if(NOT NO_SSE4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1 -msse4.2")
endif()
endif()
if(OPENCV_ROOT)
message("Searching lib in ${OPENCV_ROOT}")
find_library(OPENCV_CORE opencv_core PATHS ${OPENCV_ROOT}/lib/ NO_DEFAULT_PATH)
find_library(OPENCV_IMGPROC opencv_imgproc PATHS ${OPENCV_ROOT}/lib/ NO_DEFAULT_PATH)
find_library(OPENCV_IMGCODECS opencv_imgcodecs PATHS ${OPENCV_ROOT}/lib/ NO_DEFAULT_PATH)
find_path(OPENCV_INC opencv2/core.hpp PATHS ${OPENCV_ROOT}/include/opencv4;${OPENCV_ROOT}/include NO_DEFAULT_PATH )
else()
find_library(OPENCV_CORE opencv_core )
find_library(OPENCV_IMGPROC opencv_imgproc )
find_library(OPENCV_IMGCODECS opencv_imgcodecs )
find_path(OPENCV_INC_A opencv2/core.hpp)
if(NOT OPENCV_INC_A)
find_path(OPENCV_INC_B opencv4/opencv2/core.hpp)
if(OPENCV_INC_B)
set(OPENCV_INC "${OPENCV_INC_B}/opencv4")
else()
message("Can't find OpenCV include")
endif()
else()
set(OPENCV_INC "${OPENCV_INC_A}")
endif()
endif()
message("- OpenCV Include Path ${OPENCV_INC}")
include_directories(${OPENCV_INC})
if(WITH_CURL)
include_directories(${LIBCURL_HDR})
endif()
include_directories(${LIBZ_HDR})
if(ASI_CAMERA_HDR AND ASI_CAMERA_LIB)
include_directories(${ASI_CAMERA_HDR})
add_library(ols_driver_asi SHARED src/asi_camera.cpp)
target_link_libraries(ols_driver_asi ${ASI_CAMERA_LIB})
install(TARGETS ols_driver_asi
LIBRARY DESTINATION lib
)
message("- Building ASI Driver")
else()
message("- No ASI SDK header/lib found")
endif()
if(TOUPCAM_CAMERA_HDR AND TOUPCAM_CAMERA_LIB)
include_directories(${TOUPCAM_CAMERA_HDR})
add_library(ols_driver_toup SHARED src/toup_camera.cpp)
target_link_libraries(ols_driver_toup ${TOUPCAM_CAMERA_LIB})
install(TARGETS ols_driver_toup
LIBRARY DESTINATION lib
)
message("- Building Toupcam Driver")
else()
message("- No Toupcam SDK header/lib found")
endif()
if(LIBCFITSIO AND LIBCFITSIO_HDR AND NOT ANDROID_BUILD)
set(OLS_EXTRA ${OLS_EXTRA} src/fitsmat.cpp)
set(OLS_LIB_EXTRA ${LIBCFITSIO})
endif()
if(LIBCFITSIO AND LIBCFITSIO_HDR AND NOT ANDROID_BUILD)
include_directories(${LIBCFITSIO_HDR})
add_definitions(-DWITH_CFITSIO)
message("- Building OLS with fits support")
else()
message("- Building OLS without fits support")
endif()
add_library(ols SHARED
src/camera.cpp
src/ols.cpp
src/video_generator.cpp
src/tiffmat.cpp
src/debug_save_processor.cpp
src/post_processor.cpp
src/pre_processor.cpp
src/stacker_processor.cpp
src/common_utils.cpp
src/util.cpp
src/plate_solver.cpp
src/server_sent_events.cpp
src/downloader.cpp
src/allocator.cpp
${OLS_EXTRA}
)
target_link_libraries(ols dl ${LIBTIFF} ${LIBCPPCMS} ${LIBZ} ${LIBBOOSTER} ${OPENCV_CORE} ${OPENCV_IMGPROC} ${OPENCV_IMGCODECS} ${OLS_LIB_EXTRA})
if(ANDROID_BUILD)
target_link_libraries(ols log)
endif()
if(WITH_CURL)
target_link_libraries(ols ${LIBCURL} ${LIBZ})
endif()
if(LIBUVC)
add_library(ols_driver_uvc SHARED src/uvc_camera.cpp)
target_link_libraries(ols_driver_uvc ols ${LIBUVC})
if(ANDROID_BUILD)
target_link_libraries(ols_driver_uvc ${LIBUSB})
endif()
message("- Building UVC Driver")
install(TARGETS ols_driver_uvc
LIBRARY DESTINATION lib
)
else()
message("- No libuvc, skipping UVC Driver")
endif()
add_library(ols_driver_sim SHARED src/sim_camera.cpp)
target_link_libraries(ols_driver_sim ols ${OPENCV_IMGCODECS})
if(NOT ANDROID_BUILD AND NOT APPLE)
add_library(ols_driver_wdir SHARED src/wdir_camera.cpp)
target_link_libraries(ols_driver_wdir ols ${OPENCV_CORE} ${OPENCV_IMGPROC} ${OPENCV_IMGCODECS} ${LIBBOOSTER})
if(LIBRAW_LIB AND LIBRAW_HDR)
include_directories(${LIBRAW_HDR})
target_compile_definitions(ols_driver_wdir PRIVATE WITH_LIBRAW)
target_link_libraries(ols_driver_wdir ${LIBRAW_LIB})
message("- Building WDir driver with libraw")
install(TARGETS ols_driver_wdir
LIBRARY DESTINATION lib
)
else()
message("- Building WDir driver without libraw")
endif()
endif()
if(INDIGO_HEADER AND INDIGO_LIB AND LIBCFITSIO AND LIBCFITSIO_HDR AND NOT ANDROID_BUILD)
include_directories(${INDIGO_HEADER})
add_library(ols_driver_indigo SHARED src/indigo_camera.cpp)
target_link_libraries(ols_driver_indigo ${INDIGO_LIB})
message(" -- Building indigo camera driver")
else()
message(" -- Indigo camera driver disabled")
endif()
if(INDI_HEADER AND INDI_LIB AND LIBCFITSIO AND LIBCFITSIO_HDR AND NOT ANDROID_BUILD)
include_directories(${INDI_HEADER})
add_library(ols_driver_indi SHARED src/indi_camera.cpp)
target_link_libraries(ols_driver_indi ${INDI_LIB})
message(" -- Building indi camera driver")
else()
message(" -- Indi camera driver disabled")
endif()
if(LIBGPHOTO2_HDR AND LIBGPHOTO2_LIB AND LIBGPHOTO2_PORT_LIB)
include_directories(${LIBGPHOTO2_HDR})
add_library(ols_driver_gphoto2 SHARED src/gphoto2_camera.cpp)
target_link_libraries(ols_driver_gphoto2 ols ${LIBGPHOTO2_LIB} ${LIBGPHOTO2_PORT_LIB} ${OPENCV_CORE} ${OPENCV_IMGCODECS} ${OPENCV_IMGPROC})
if(LIBRAW_LIB AND LIBRAW_HDR)
include_directories(${LIBRAW_HDR})
set_target_properties(ols_driver_gphoto2 PROPERTIES COMPILE_DEFINITIONS WITH_LIBRAW)
target_link_libraries(ols_driver_gphoto2 ${LIBRAW_LIB})
message("- Building GPhoto2 Driver with libraw")
else()
message("- Building GPhoto2 Driver without libraw")
endif()
install(TARGETS ols_driver_gphoto2
LIBRARY DESTINATION lib
)
else()
message("- No GPhoto2 header/lib found")
endif()
if(ANDROID_BUILD)
if(LIBCAMERA2_HDR AND LIBCAMERA2_LIB AND LIBMEDIANDK_HDR AND LIBMEDIANDK_LIB)
include_directories(LIBCAMERA2_HDR)
include_directories(LIBMEDIANDK_HDR)
add_library(ols_driver_android SHARED src/android_camera.cpp)
target_link_libraries(ols_driver_android ols ${OPENCV_CORE} ${LIBCAMERA2_LIB} ${LIBMEDIANDK_LIB} android)
message("- Building Android camera driver ")
install(TARGETS ols_driver_android
LIBRARY DESTINATION lib
)
else()
message("- No Android Ndk Camera2 header/lib found, disabling android camera support")
endif()
endif()
install(TARGETS ols ols_driver_sim
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
if(NOT ANDROID_BUILD)
include_directories(src)
add_executable(test_indigo_format_parsing test/test_indigo_format_parsing.cpp)
add_executable(test_camera test/test_camera.cpp)
add_executable(ols_cmd src/ols_cmd.cpp)
add_executable(offline_ols test/offline_sim.cpp)
add_executable(ols_plate_solver_test test/plate_solver_test.cpp)
target_link_libraries(test_camera ols)
target_link_libraries(ols_cmd ols)
target_link_libraries(offline_ols ols)
target_link_libraries(ols_plate_solver_test ols ${OPENCV_CORE} ${OPENCV_IMGPROC} ${OPENCV_IMGCODECS})
target_link_libraries(test_indigo_format_parsing ols)
install(TARGETS ols_driver_sim ols_cmd offline_ols
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
endif()
add_custom_command(TARGET ols POST_BUILD
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/make_db.py ${CMAKE_CURRENT_SOURCE_DIR}/www-data/media/js/jsdb.js
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building DB"
)