File: CMakeLists.txt

package info (click to toggle)
eckit 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,044 kB
  • sloc: cpp: 111,103; ansic: 2,826; yacc: 590; lex: 361; python: 302; sh: 162; makefile: 53
file content (364 lines) | stat: -rw-r--r-- 11,940 bytes parent folder | download
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
# (C) Copyright 2011- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

########################################################################################################################


cmake_minimum_required( VERSION 3.18 FATAL_ERROR )

find_package( ecbuild 3.7 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)

project( eckit LANGUAGES CXX )

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

########################################################################################################################
### dependencies and options

ecbuild_add_option( FEATURE BUILD_TOOLS
                    DEFAULT ON
                    DESCRIPTION "Build the command line tools" )

ecbuild_add_option( FEATURE EXPERIMENTAL
                    DEFAULT OFF
                    DESCRIPTION "Experimental features that havent graduated to production ready code" )

ecbuild_add_option( FEATURE SANDBOX
                    DEFAULT OFF
                    DESCRIPTION "Sandbox playground for prototyping code that may never see the light of day" )

### thread library ( preferably pthreads ) --- Must be called before FindCUDA!

if( ${CMAKE_VERSION} VERSION_LESS 3.14 )
    # Following variable is unused for CMake > 3.14
    set( CMAKE_THREAD_PREFER_PTHREAD 1 )
endif()

if( NOT DEFINED THREADS_PREFER_PTHREAD_FLAG )
  set( THREADS_PREFER_PTHREAD_FLAG 1 )
endif()

### Set THREADS_HAVE_PTHREAD_ARG variable to false so that it can be recomputed based on
### THREADS_PREFER_PTHREAD_FLAG, in case other project had it on a different setting.
### This is certainly a CMake bug ( see ECKIT-426 )
set( THREADS_HAVE_PTHREAD_ARG FALSE )
find_package( Threads REQUIRED )
set( THREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} )

ecbuild_add_option( FEATURE ECKIT_MEMORY_FACTORY_BUILDERS_DEBUG
                    DEFAULT OFF
                    DESCRIPTION "eckit::Factory builders debug"
                    ADVANCED )

ecbuild_add_option( FEATURE ECKIT_MEMORY_FACTORY_EMPTY_DESTRUCTION
                    DEFAULT OFF
                    DESCRIPTION "eckit::Factory empty destruction (system dependant)"
                    ADVANCED )

### eckit::mpi

ecbuild_add_option( FEATURE MPI
                    DEFAULT ON
                    DESCRIPTION "Use system MPI libraries"
                    REQUIRED_PACKAGES "MPI COMPONENTS C" )

### eckit::cmd

ecbuild_find_lexyacc()

ecbuild_add_option( FEATURE ECKIT_CMD
                    DEFAULT ON
                    DESCRIPTION "Utilities for administration tools"
                    CONDITION LEXYACC_FOUND
                    REQUIRED_PACKAGES "Curses" )

### eckit::sql

ecbuild_add_option( FEATURE ECKIT_SQL
                    DEFAULT ON
                    DESCRIPTION "An SQL engine"
                    CONDITION LEXYACC_FOUND )

### Eigen

ecbuild_add_option( FEATURE EIGEN
                    DESCRIPTION "Eigen linear algebra library"
                    REQUIRED_PACKAGES Eigen3 )

set_package_properties( Eigen3 PROPERTIES
                        DESCRIPTION "C++ template library for linear algebra"
                      )

### OpenMP

ecbuild_add_option( FEATURE OMP
                    DEFAULT OFF
                    DESCRIPTION "OpenMP linear algebra backend"
                    REQUIRED_PACKAGES "OpenMP COMPONENTS CXX" )

if( NOT TARGET OpenMP::OpenMP_CXX )
    set( eckit_HAVE_OMP 0 )
endif()

### RADOS

ecbuild_add_option( FEATURE RADOS
                    DEFAULT OFF
                    DESCRIPTION "Ceph/Rados storage support"
                    REQUIRED_PACKAGES RADOS )

### MKL

ecbuild_add_option( FEATURE MKL
                    DESCRIPTION "MKL linear algebra library"
                    REQUIRED_PACKAGES MKL )

### Compression options

ecbuild_add_option( FEATURE BZIP2
                    DESCRIPTION "BZip2 support for compression"
                    REQUIRED_PACKAGES BZip2 )

ecbuild_add_option( FEATURE SNAPPY
                    DESCRIPTION "Snappy support for compression"
                    REQUIRED_PACKAGES Snappy )

ecbuild_add_option( FEATURE LZ4
                    DESCRIPTION "LZ4 support for compression"
                    REQUIRED_PACKAGES LZ4 )

ecbuild_add_option( FEATURE AEC
                    DESCRIPTION "AEC support for compression"
                    REQUIRED_PACKAGES "NAME libaec VERSION 1.1.4")

ecbuild_add_option( FEATURE ZIP
                    DESCRIPTION "ZIP support for compression"
                    REQUIRED_PACKAGES libzip )

### Hashing options

ecbuild_add_option( FEATURE XXHASH
                    DESCRIPTION "xxHash support for hashing" )

### eckit::codec

ecbuild_add_option( FEATURE ECKIT_CODEC
                    DEFAULT ON
                    DESCRIPTION "eckit::codec encoding/decoding library" )

set( eckit_CODEC_STATIC_ASSERT ON CACHE BOOL "eckit::codec static assertions" )

### eckit::spec

ecbuild_add_option( FEATURE ECKIT_SPEC
                    DEFAULT ON
                    DESCRIPTION "eckit::spec metadata library" )

### eckit::maths

ecbuild_add_option( FEATURE CONVEX_HULL
                    DEFAULT OFF
                    DESCRIPTION "eckit::maths library convex hull/Delaunay triangulation" )
                    # REQUIRED_PACKAGES "Qhull COMPONENTS C CXX"

if( eckit_HAVE_CONVEX_HULL )
    find_package( Qhull REQUIRED CONFIG )

    if( NOT TARGET Qhull::qhullcpp OR NOT TARGET Qhull::qhullstatic_r )
        message( FATAL_ERROR "eckit::maths ENABLE_CONVEX_HULL requires Qhull C/C++ libraries" )
    endif()

    add_library(Qhull::Qhull INTERFACE IMPORTED)
    target_link_libraries(Qhull::Qhull INTERFACE Qhull::qhullcpp Qhull::qhullstatic_r )
endif()

### eckit::geo

ecbuild_add_option( FEATURE ECKIT_GEO
                    DEFAULT ON
                    DESCRIPTION "eckit::geo geometry library" )

ecbuild_add_option( FEATURE GEO_CACHING
                    DEFAULT OFF
                    CONDITION eckit_HAVE_ECKIT_GEO
                    DESCRIPTION "eckit::geo geometry library default caching behaviour" )

ecbuild_add_option( FEATURE GEO_BITREPRODUCIBLE
                    DEFAULT OFF
                    CONDITION eckit_HAVE_ECKIT_GEO
                    DESCRIPTION "eckit::geo geometry library bit reproducibility tests" )

ecbuild_add_option( FEATURE GEO_PROJECTION_PROJ_DEFAULT
                    DEFAULT OFF
                    CONDITION eckit_HAVE_ECKIT_GEO
                    DESCRIPTION "eckit::geo geometry library default to PROJ-based projections" )

ecbuild_add_option( FEATURE GEO_AREA_SHAPEFILE
                    DEFAULT ON
                    CONDITION eckit_HAVE_ECKIT_GEO AND eckit_HAVE_ZIP
                    REQUIRED_PACKAGES shapelib
                    DESCRIPTION "eckit::geo geometry library support for shapefiles" )

set( ECKIT_GEO_CODEC_GRIDS OFF )
if( eckit_HAVE_ECKIT_CODEC AND eckit_HAVE_LZ4 )
    set( ECKIT_GEO_CODEC_GRIDS ON )
endif()

if( eckit_HAVE_GEO_AREA_SHAPEFILE )
    if( NOT TARGET shapelib::shp OR NOT TARGET libzip::zip )
        message( FATAL_ERROR "eckit::geo geometry library support for shapefiles requires the shapelib::shp and libzip::zip libraries" )
    endif()
endif()

# (keep paths as strings to avoid normalisation/expansion)
set( eckit_GEO_CACHE_PATH "~/.local/share/eckit/geo" CACHE STRING "eckit::geo cache path default" )
set( eckit_GEO_SHARE_URL_PREFIX "https://sites.ecmwf.int/repository/eckit/geo" CACHE STRING "eckit::geo URL prefix for downloadable assets" )

### LAPACK

if( eckit_HAVE_MKL )
    set( eckit_HAVE_LAPACK 1 )
    set( LAPACK_LIBRARIES ${MKL_LIBRARIES} )
else()
    ecbuild_add_option( FEATURE LAPACK
                        DESCRIPTION "Linear Algebra PACKage"
                        REQUIRED_PACKAGES "LAPACK QUIET" )
endif()

### OpenSSL (for SHA1 and MD4)

ecbuild_add_option( FEATURE SSL
                    DEFAULT OFF # We only use deprecated functionality from OpenSSL
                    DESCRIPTION "OpenSSL support"
                    REQUIRED_PACKAGES OpenSSL )

if( OPENSSL_FOUND )
  ecbuild_info("OpenSSL version ${OPENSSL_VERSION} -- libs [${OPENSSL_LIBRARIES}] incs [${OPENSSL_INCLUDE_DIR}]")
endif()

#### Curl

ecbuild_add_option( FEATURE CURL
                    DESCRIPTION "Curl library for transfering data with URLs"
                    REQUIRED_PACKAGES "CURL 7.20" )

if(HAVE_CURL)
  ecbuild_info("Curl version ${CURL_VERSION_STRING} -- libs [${CURL_LIBRARIES}] incs [${CURL_INCLUDE_DIRS}]")
endif()

#### CUDA

ecbuild_add_option( FEATURE CUDA
                    DEFAULT OFF
                    DESCRIPTION "CUDA GPU linear algebra operations"
                    REQUIRED_PACKAGES CUDAToolkit )

#### HIP

ecbuild_add_option( FEATURE HIP
                    DEFAULT OFF
                    DESCRIPTION "HIP GPU linear algebra operations"
                    REQUIRED_PACKAGES hip hipsparse )

### Performance tests

ecbuild_add_option( FEATURE EXTRA_TESTS
                    DEFAULT OFF
                    DESCRIPTION "Add additional unit/performance tests" )

### UNICODE support

check_include_file_cxx("codecvt" HAVE_CXX_CODECVT)

ecbuild_add_option( FEATURE UNICODE
                    DEFAULT ON
                    CONDITION HAVE_CXX_CODECVT
                    DESCRIPTION "Add support for Unicode characters in Yaml/JSON parsers" )

### async io support

find_package( AIO )
ecbuild_add_option( FEATURE AIO
                    DEFAULT ON
                    CONDITION ${AIO_FOUND}
                    DESCRIPTION "support for asynchronous IO")

### PROJ support

ecbuild_add_option( FEATURE PROJ
                    DEFAULT OFF
                    DESCRIPTION "support PROJ-based projections"
                    REQUIRED_PACKAGES "PROJ 9.1.1" )

ecbuild_add_option(
    FEATURE DOCS
    DEFAULT OFF
    DESCRIPTION "Enable documentation generation"
)

### c math library, needed when including "math.h"

find_package( CMath )

### realtime library implements shm_open on Linux
if( CMAKE_SYSTEM_NAME MATCHES "Linux" )
    find_package( Realtime )
    if( REALTIME_FOUND ) # check that aio needs realtime
        set( RT_LIBRARIES ${RT_LIB} )
    endif()
else()
    set( RT_LIBRARIES "" )
endif()

### sanity checks

include(cmake/check_time_t_Y2038.cmake) # check Y2038 time_t compatibility

# check thread library is pthreads
if( NOT ${CMAKE_USE_PTHREADS_INIT} )
    message( FATAL_ERROR "Only pthreads supported - thread library found is [${THREADS_LIBRARIES}]" )
endif()

############################################################################################
# sources

include(cmake/compiler_warnings.cmake) # optionally handle compiler specific warnings

set( PERSISTENT_NAMESPACE "eckit" CACHE INTERNAL "" ) # needed for generating .b files for persistent support

add_subdirectory( src )
if(eckit_HAVE_DOCS)
    add_subdirectory(docs)
endif()
add_subdirectory( share )

if( eckit_HAVE_TESTS )
    add_subdirectory( tests )
    add_subdirectory( regressions )
endif()

ecbuild_add_resources( TARGET ${PROJECT_NAME}_top_files
                       SOURCES AUTHORS README.md NOTICE LICENSE
                       INSTALL ChangeLog COPYING )

############################################################################################
# finalize

set( ECKIT_LIBRARIES ${eckit_ALL_LIBS} ) # used for ecbuild_pkgconfig

foreach( _lib ${ECKIT_LIBRARIES} )
    ecbuild_pkgconfig( NAME ${_lib}
                       DESCRIPTION "ECMWF C++ Toolkit - ${_lib} library"
                       URL "https://software.ecmwf.int/wiki/display/ECKIT/ecKit"
                       LIBRARIES ${_lib} )
endforeach()

ecbuild_install_project( NAME ${PROJECT_NAME} )

ecbuild_print_summary()