-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
304 lines (265 loc) · 9.54 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
cmake_minimum_required(VERSION 3.10)
project(carta_backend)
include_directories(src)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(CMAKE_LINK_DIRECTORIES_BEFORE ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/third-party/install)
include(uWebSockets)
if(DEPLOYMENT_TYPE)
add_definitions(-DDEPLOYMENT_TYPE="${DEPLOYMENT_TYPE}")
endif()
# Enable OpenMP if package is found
find_package(OpenMP)
if (OPENMP_CXX_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else ()
message(WARNING "OpenMP not found!")
endif ()
# Use the -march=native flags when building on the same architecture as deploying to get a slight performance
# increase when running CPU intensive tasks such as compression and down-sampling of data. If targeting AVX-capable
# processes only, set EnableAvx to ON
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
option(EnableAvx "Enable AVX codepaths instead of SSE4" OFF)
# Automatically detect if building on an ARM based system such as the Apple M1.
# It will replace SSE functions with ARM NEON functions using sse2neon.h from
# https://github.com/DLTcollab/sse2neon, redistributable under the MIT License.
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ARM_ARCH_ -march=armv8-a+fp+simd+crypto+crc")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64" AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ARM_ARCH_ -march=armv8-a+fp+simd+crypto+crc")
elseif (EnableAvx)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4")
endif ()
# Needed by clang-tidy and other clang tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
FIND_PACKAGE(GSL QUIET)
if (GSL_FOUND)
message(STATUS "Found gsl using find_package")
else ()
if(EXISTS /opt/carta-gsl)
message(STATUS "Found carta-gsl for el7")
INCLUDE_DIRECTORIES(/opt/carta-gsl/include)
LINK_DIRECTORIES(/opt/carta-gsl/lib)
else ()
message(FATAL_ERROR "Could not find gsl")
endif ()
endif()
FIND_PACKAGE(ZFP CONFIG REQUIRED)
FIND_PACKAGE(PkgConfig REQUIRED)
FIND_PACKAGE(CFITSIO QUIET)
if (CFITSIO_FOUND)
message(STATUS "Found cfitsio using find_package")
else ()
PKG_SEARCH_MODULE(CFITSIO REQUIRED cfitsio)
if (CFITSIO_FOUND)
message(STATUS "Found cfitsio using pkg-config")
include_directories (${CFITSIO_INCLUDE_DIRS})
else ()
message(FATAL_ERROR "Could not find cfitsio")
endif ()
endif()
FIND_PACKAGE(WCSLIB QUIET)
if (WCSLIB_FOUND)
message(STATUS "Found wcslib using find_package")
else ()
PKG_SEARCH_MODULE(WCSLIB REQUIRED wcslib)
if (WCSLIB_FOUND)
message(STATUS "Found wcslib using pkg-config")
else ()
message(FATAL_ERROR "Could not find wcslib")
endif ()
endif()
PKG_SEARCH_MODULE(UUID REQUIRED uuid)
if (UUID_FOUND)
message(STATUS "Found uuid using pkg-config")
else ()
message(FATAL_ERROR "Could not find uuid")
endif ()
PKG_SEARCH_MODULE(ZSTD REQUIRED libzstd)
if (ZSTD_FOUND)
message(STATUS "zstd found using pkg-config")
else ()
message(FATAL_ERROR "Could not find zstd")
endif ()
FIND_PACKAGE(HDF5 REQUIRED COMPONENTS CXX)
FIND_PACKAGE(Protobuf REQUIRED)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
if (Protobuf_VERSION VERSION_GREATER_EQUAL "4.25.3")
FIND_PACKAGE(absl REQUIRED)
set(PROTOBUF_LIBRARY
${PROTOBUF_LIBRARY}
absl_hash
absl_log_internal_message
absl_log_internal_nullguard)
message(STATUS "Newer protobuf version (${Protobuf_VERSION}) includes abseil libraries")
endif ()
FIND_PACKAGE(Threads)
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
ADD_SUBDIRECTORY(carta-protobuf)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
if (NOT CARTA_CASACORE_ROOT)
set(CARTA_CASACORE_ROOT /opt/carta-casacore)
endif()
set(CARTA_CASACORE_INCLUDE_DIRS
${CARTA_CASACORE_ROOT}/include
${CARTA_CASACORE_ROOT}/include/casacore
${CARTA_CASACORE_ROOT}/include/casacode)
option(DevSuppressExternalWarnings "Suppress external warnings (developer use only)" OFF)
if (DevSuppressExternalWarnings)
message(STATUS "disabling warnings from carta-casacore")
INCLUDE_DIRECTORIES(SYSTEM ${CARTA_CASACORE_INCLUDE_DIRS})
else()
INCLUDE_DIRECTORIES(${CARTA_CASACORE_INCLUDE_DIRS})
endif()
LINK_DIRECTORIES(${CARTA_CASACORE_ROOT}/lib)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
INCLUDE_DIRECTORIES(/usr/local/include)
INCLUDE_DIRECTORIES(/usr/local/opt/openssl/include)
INCLUDE_DIRECTORIES(/usr/local/opt/libomp/include)
LINK_DIRECTORIES(/usr/local/lib)
LINK_DIRECTORIES(/usr/local/opt)
LINK_DIRECTORIES(/opt/homebrew/lib)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (DisableContourCompression)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_DISABLE_CONTOUR_COMPRESSION_")
endif (DisableContourCompression)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION LESS 11.2.0)
set(LINK_LIBS ${LINK_LIBS} stdc++fs)
endif ()
# Include uWebSockets headers and build the uSockets lib
include_directories(${CMAKE_SOURCE_DIR}/third-party/include)
install_uWebSockets()
#pugixml
include_directories(${CMAKE_SOURCE_DIR}/third-party/pugixml/src)
#spdlog
add_subdirectory(third-party/spdlog)
set(LINK_LIBS
${LINK_LIBS}
carta-protobuf
${PROTOBUF_LIBRARY}
uSockets
uuid
z
zfp
zstd
cfitsio
wcs
gsl
casa_casa
casa_coordinates
casa_tables
casa_images
casa_lattices
casa_fits
casa_measures
casa_mirlib
casa_scimath
casa_imageanalysis
${OpenMP_CXX_LIBRARIES}
${HDF5_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
set(SOURCE_FILES
${SOURCE_FILES}
third-party/pugixml/src/pugixml.cpp
src/Cache/LoaderCache.cc
src/Cache/TileCache.cc
src/Cache/TilePool.cc
src/DataStream/Compression.cc
src/DataStream/Contouring.cc
src/DataStream/Smoothing.cc
src/DataStream/Tile.cc
src/DataStream/VectorField.cc
src/FileList/FileExtInfoLoader.cc
src/FileList/FileInfoLoader.cc
src/FileList/FileListHandler.cc
src/FileList/FitsHduList.cc
src/Frame/Frame.cc
src/HttpServer/HttpServer.cc
src/ImageData/CartaFitsImage.cc
src/ImageData/CartaHdf5Image.cc
src/ImageData/CartaMiriadImage.cc
src/ImageData/CompressedFits.cc
src/ImageData/FileInfo.cc
src/ImageData/FileLoader.cc
src/ImageData/FitsLoader.cc
src/ImageData/Hdf5Attributes.cc
src/ImageData/Hdf5Loader.cc
src/ImageData/PolarizationCalculator.cc
src/ImageData/StokesFilesConnector.cc
src/ImageGenerators/MomentGenerator.cc
src/ImageGenerators/PvGenerator.cc
src/ImageGenerators/PvPreviewCube.cc
src/ImageGenerators/PvPreviewCut.cc
src/ImageStats/Histogram.cc
src/ImageStats/StatsCalculator.cc
src/Logger/Logger.cc
src/Logger/CartaLogSink.cc
src/Main/Main.cc
src/Main/ProgramSettings.cc
src/Main/WebBrowser.cc
src/Region/CrtfImportExport.cc
src/Region/Ds9ImportExport.cc
src/Region/LineBoxRegions.cc
src/Region/Region.cc
src/Region/RegionConverter.cc
src/Region/RegionHandler.cc
src/Region/RegionImportExport.cc
src/Session/CursorSettings.cc
src/Session/OnMessageTask.cc
src/Session/Session.cc
src/Session/SessionManager.cc
src/Table/Columns.cc
src/Table/Table.cc
src/Table/TableController.cc
src/Table/TableView.cc
src/ThreadingManager/ThreadingManager.cc
src/Timer/ListProgressReporter.cc
src/Timer/Timer.cc
src/Util/App.cc
src/Util/Casacore.cc
src/Util/File.cc
src/Util/Message.cc
src/Util/Stokes.cc
src/Util/String.cc
src/Util/Token.cc
src/ImageFitter/ImageFitter.cc
src/Util/RemoteFiles.cc
src/Util/RemoteFiles.h)
add_definitions(-DHAVE_HDF5 -DPUGIXML_COMPACT)
add_executable(carta_backend ${SOURCE_FILES})
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list(REMOVE_ITEM LINK_LIBS uuid)
target_link_libraries(carta_backend uv ${LINK_LIBS})
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(carta_backend ${LINK_LIBS})
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (CartaUserFolderPrefix)
add_definitions(-DCARTA_USER_FOLDER_PREFIX="${CartaUserFolderPrefix}")
endif (CartaUserFolderPrefix)
if (CartaDefaultFrontendFolder)
add_definitions(-DCARTA_DEFAULT_FRONTEND_FOLDER="${CartaDefaultFrontendFolder}")
endif (CartaDefaultFrontendFolder)
install(TARGETS carta_backend
RUNTIME DESTINATION bin)
install(PROGRAMS "${CMAKE_SOURCE_DIR}/scripts/carta"
DESTINATION bin)
install(FILES "${CMAKE_SOURCE_DIR}/static/default_image/default.fits"
DESTINATION share/carta)
# Tests
option(test "Build tests." OFF)
if (test)
FIND_PACKAGE(GTest REQUIRED)
add_subdirectory(test)
endif ()