-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
336 lines (285 loc) · 8.5 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
# Diana - A Free Meteorological Visualisation Tool
#
# Copyright (C) 2017-2022 met.no
#
# Contact information:
# Norwegian Meteorological Institute
# Box 43 Blindern
# 0313 OSLO
# NORWAY
# email: [email protected]
#
# This file is part of Diana
#
# Diana 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 2 of the License, or
# (at your option) any later version.
#
# Diana 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 Diana; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
PROJECT(diana)
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
INCLUDE(MetnoUtils)
INCLUDE(MetnoQtUtils)
INCLUDE(MetnoVersions)
INCLUDE(MetnoFindPackage)
METNO_CMAKE_SETUP()
METNO_PVERSION(3.59.0)
OPTION(ENABLE_DIANA_OMP "Use OpenMP" OFF)
OPTION(ENABLE_PERL "Build perl module" OFF)
OPTION(ENABLE_TESTS "Build and run tests" ON)
OPTION(ENABLE_NEWARKOBS "Enable NEWARK observations" OFF)
OPTION(ENABLE_MITIFF "Enable MiTiff support" ON)
OPTION(ENABLE_GEOTIFF "Enable GeoTiff support" OFF)
OPTION(ENABLE_OBS_BUFR "Enable observation from BUFR files" ON)
OPTION(ENABLE_HDF5 "Enable HDF5 file support" OFF)
OPTION(ENABLE_GRPC "Enable gRPC services" OFF)
IF(ENABLE_DIANA_OMP)
SET(HAVE_OPENMP TRUE)
FIND_PACKAGE(OpenMP REQUIRED)
SET(openmp_PACKAGE OpenMP::OpenMP_CXX)
ENDIF()
IF (ENABLE_TESTS)
INCLUDE(MetnoGTest)
ENDIF (ENABLE_TESTS)
SET(THREADS_PREFER_PTHREAD_FLAG TRUE)
FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(Boost COMPONENTS date_time REQUIRED)
FIND_PACKAGE(yaml-cpp REQUIRED)
FIND_PACKAGE(mi-programoptions "2.0.0" REQUIRED)
FIND_PACKAGE(mi-fieldcalc "0.1.0" REQUIRED)
FIND_PACKAGE(fimex "2.0" REQUIRED)
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS
Gui
LinguistTools
Network
OpenGL
PrintSupport
Svg
Xml
XmlPatterns
)
SET(PKGS_CORE
Qt5::Network
Qt5::PrintSupport # needed for svg export, see SvgFileSink.cc
Qt5::Svg
Qt5::Xml
Qt5::XmlPatterns
Boost::boost
Boost::date_time # only used by FimexIO.cc
libfimex
mi-fieldcalc
yaml-cpp
${openmp_PACKAGE}
)
SET(PKGS_UI
Qt5::Gui
Qt5::OpenGL
)
METNO_FIND_PACKAGE(milogger
VERSION_MIN "6.0.4"
PKGCONFIG_NAME metlibs-milogger
)
LIST(APPEND PKGS_CORE ${milogger_PACKAGE})
METNO_FIND_PACKAGE(putools
VERSION_MIN "8.0.0"
PKGCONFIG_NAME metlibs-putools
)
LIST(APPEND PKGS_CORE ${putools_PACKAGE})
METNO_FIND_PACKAGE(pudatatypes
VERSION_MIN "6.0.0"
PKGCONFIG_NAME metlibs-pudatatypes
)
LIST(APPEND PKGS_CORE ${pudatatypes_PACKAGE})
METNO_FIND_PACKAGE(libpng
VERSION_MIN "1.2"
PKGCONFIG_NAME libpng
)
LIST(APPEND PKGS_CORE ${libpng_PACKAGE})
METNO_FIND_PACKAGE(libcurl
VERSION_MIN "7"
PKGCONFIG_NAME libcurl
)
LIST(APPEND PKGS_CORE ${libcurl_PACKAGE})
METNO_FIND_PACKAGE(proj
PKGCONFIG_NAME "proj"
LIBRARY_NAME "proj"
INCLUDE_HDR "proj.h" "proj_api.h"
)
MESSAGE (STATUS "proj version='${proj_PACKAGE_VERSION}'")
IF (proj_PACKAGE_VERSION STREQUAL "")
# unknown version
IF ("${proj_HEADER}" STREQUAL "proj.h")
SET(HAVE_PROJ_H 1)
ENDIF()
ELSEIF (proj_PACKAGE_VERSION VERSION_LESS "4.6.0")
# <4.6
MESSAGE(SEND_ERROR "proj version '${proj_PACKAGE_VERSION}' is too old")
ELSEIF (${proj_PACKAGE_VERSION} VERSION_LESS "5.0.0")
# >=4.6,<5.0
# proj_api.h
ELSEIF (${proj_PACKAGE_VERSION} VERSION_LESS "6.2.0")
# >=5.0,<6.2
MESSAGE(SEND_ERROR "proj version '${proj_PACKAGE_VERSION}' not supported")
ELSEIF (${proj_PACKAGE_VERSION} VERSION_LESS "8.0.0")
# >=6.2,<8.0
# ok, proj_api.h
ELSE ()
# >=8.0
SET(HAVE_PROJ_H 1)
ENDIF()
LIST(APPEND PKGS_CORE ${proj_PACKAGE})
METNO_FIND_PACKAGE(shp
PKGCONFIG_NAME shapelib
LIBRARY_NAME "shp"
INCLUDE_HDR "shapefil.h"
)
LIST(APPEND PKGS_CORE ${shp_PACKAGE})
METNO_FIND_PACKAGE(udunits2
VERSION_MIN "2"
PKGCONFIG_NAME udunits
LIBRARY_NAME "udunits2"
INCLUDE_HDR "udunits2.h"
)
LIST(APPEND PKGS_CORE ${udunits2_PACKAGE})
IF (ENABLE_GRPC)
# see https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/CMakeLists.txt#L97
SET (GRPC_MIN_VERSION "1.3.2")
find_package(gRPC ${GRPC_MIN_VERSION} CONFIG)
if (gRPC_FOUND)
message(STATUS "Using gRPC ${gRPC_VERSION} from cmake config")
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED)
message(STATUS "Using protobuf ${Protobuf_VERSION}")
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
set(_REFLECTION gRPC::grpc++_reflection)
if(CMAKE_CROSSCOMPILING)
find_program(_PROTOBUF_PROTOC protoc)
else()
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
endif()
set(_GRPC_GRPCPP gRPC::grpc++)
if(CMAKE_CROSSCOMPILING)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
else()
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
endif()
SET(GRPC_LIBRARIES ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF})
SET(PROTOC ${_PROTOBUF_PROTOC})
SET(PROTOC_GEN_GRPC ${_GRPC_CPP_PLUGIN_EXECUTABLE})
SET(GRPC_VERSION ${gRPC_VERSION})
ELSE()
PKG_CHECK_MODULES(PC_GRPC REQUIRED IMPORTED_TARGET grpc++>=${GRPC_MIN_VERSION} protobuf)
SET(GRPC_LIBRARIES PkgConfig::PC_GRPC Threads::Threads)
SET(GRPC_VERSION ${PC_GRPC_grpc++_VERSION})
message(STATUS "Using gRPC++ ${GRPC_VERSION} from pkg-config")
find_program(_PROTOBUF_PROTOC protoc)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
ENDIF()
# changed header files in grpc 1.10.0, see https://github.com/grpc/grpc/releases/tag/v1.10.0
IF (GRPC_VERSION VERSION_LESS "1.10")
SET(DIANA_GRPC_INCLUDES_IN_GRPCPP 0)
ELSE()
SET(DIANA_GRPC_INCLUDES_IN_GRPCPP 1)
ENDIF()
ENDIF (ENABLE_GRPC)
IF (ENABLE_GEOTIFF)
SET (GEOTIFF_HDRS libgeotiff/geotiff.h geotiff/geotiff.h geotiff.h)
METNO_FIND_PACKAGE(geotiff
LIBRARY_NAME geotiff
INCLUDE_HDR ${GEOTIFF_HDRS}
)
LIST(APPEND PKGS_CORE ${geotiff_PACKAGE})
UNSET (HAVE_LIBGEOTIFF_GEOTIFF_H CACHE)
UNSET (HAVE_GEOTIFF_GEOTIFF_H CACHE)
UNSET (HAVE_GEOTIFF_H CACHE)
IF ("${geotiff_HEADER}" STREQUAL "libgeotiff/geotiff.h")
SET (HAVE_LIBGEOTIFF_GEOTIFF_H TRUE)
ELSEIF ("${geotiff_HEADER}" STREQUAL "geotiff/geotiff.h")
SET (HAVE_GEOTIFF_GEOTIFF_H TRUE)
ELSEIF ("${geotiff_HEADER}" STREQUAL "geotiff.h")
SET (HAVE_GEOTIFF_H TRUE)
ELSE ()
MESSAGE (FATAL_ERROR "Unsupported geotiff.h subdirectory: '${geotiff_HEADER}'")
ENDIF ()
SET(DIANA_SAT_GEOTIFF TRUE)
ENDIF ()
IF (ENABLE_HDF5)
METNO_FIND_PACKAGE(hdf5
PKGCONFIG_NAME hdf5-serial
LIBRARY_NAME "hdf5_serial;hdf5"
INCLUDE_HDR "hdf5.h"
)
LIST(APPEND PKGS_CORE ${hdf5_PACKAGE})
SET(DIANA_SAT_HDF5 TRUE) # for diana_config.h
ENDIF ()
IF (ENABLE_MITIFF)
METNO_FIND_PACKAGE(libtiff
PKGCONFIG_NAME libtiff-4
)
LIST(APPEND PKGS_CORE ${libtiff_PACKAGE})
SET(DIANA_SAT_MITIFF TRUE) # for diana_config.h
ENDIF ()
IF (ENABLE_NEWARKOBS)
METNO_FIND_PACKAGE(newark
PKGCONFIG_NAME newarkAPI
)
LIST(APPEND PKGS_CORE ${newark_PACKAGE})
SET(ROADOBS TRUE)
SET(NEWARK_INC TRUE)
ENDIF ()
IF (ENABLE_OBS_BUFR)
METNO_FIND_PACKAGE(emos
CMAKE_NAME libemos
CMAKE_TARGETS emos_shared
PKGCONFIG_NAME emos
)
LIST(APPEND PKGS_CORE ${emos_PACKAGE})
SET(BUFROBS TRUE)
ENDIF ()
# these are for libdianaui only
METNO_FIND_PACKAGE(coserver
VERSION_MIN "3.0.0"
PKGCONFIG_NAME metlibs-coserver-qt5
)
LIST(APPEND PKGS_UI ${coserver_PACKAGE})
METNO_FIND_PACKAGE(qutilities
VERSION_MIN "8.0.0"
PKGCONFIG_NAME metlibs-qutilities-qt5
)
LIST(APPEND PKGS_UI ${qutilities_PACKAGE})
METNO_FIND_PACKAGE(ftgl
PKGCONFIG_NAME ftgl
)
LIST(APPEND PKGS_UI ${ftgl_PACKAGE})
METNO_FIND_PACKAGE(glu
PKGCONFIG_NAME glu
)
LIST(APPEND PKGS_UI ${glu_PACKAGE})
# where libdiana...*so private shared libraries are installed
SET (LIBDIANA_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/diana/${PVERSION}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${LIBDIANA_DIR}" INSTALL_LIBDIR_IS_SYSTEM_DIR)
IF(${INSTALL_LIBDIR_IS_SYSTEM_DIR} EQUAL -1)
LIST(APPEND CMAKE_INSTALL_RPATH "${LIBDIANA_DIR}")
ENDIF()
IF (ENABLE_TESTS)
ENABLE_TESTING()
ENDIF (ENABLE_TESTS)
ADD_SUBDIRECTORY(src)
IF (ENABLE_TESTS)
ADD_SUBDIRECTORY(test)
ENDIF (ENABLE_TESTS)
IF (ENABLE_PERL)
ADD_SUBDIRECTORY(perl)
ENDIF (ENABLE_PERL)
ADD_SUBDIRECTORY(etc)
ADD_SUBDIRECTORY(share)