-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
129 lines (99 loc) · 4.55 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
cmake_minimum_required( VERSION 3.12 FATAL_ERROR )
find_package( ecbuild 3.7 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
project( gribjump LANGUAGES C CXX )
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
########################################################################################################################
### dependencies and options
set( PERSISTENT_NAMESPACE "eckit" CACHE INTERNAL "" ) # needed for generating .b files for persistent support
ecbuild_find_package( NAME eckit VERSION 1.25.2 REQUIRED )
ecbuild_find_package( NAME metkit VERSION 1.5 REQUIRED )
# Set "GRIBJUMP_LOCAL_EXTRACT" to build everything. If it is off, build only minimal clientside functionality.
ecbuild_add_option( FEATURE GRIBJUMP_LOCAL_EXTRACT
DEFAULT ON
DESCRIPTION "Build local extraction and serverside functionality")
if (HAVE_GRIBJUMP_LOCAL_EXTRACT)
ecbuild_find_package( NAME fdb5 VERSION 5.13.1 REQUIRED )
set(GRIBJUMP_HAVE_FDB 1)
ecbuild_find_package( NAME eccodes VERSION 2.32.1 REQUIRED )
### AEC
# Override eccodes' aec with our own: we need a newer version.
unset(AEC_INCLUDE_DIRS CACHE)
unset(AEC_LIBRARIES CACHE)
ecbuild_find_package( NAME AEC VERSION 1.1.1 REQUIRED )
# ecbuild_find_package's version checking does not work if the version is not specified in the package.
if (NOT AEC_VERSION)
message(FATAL_ERROR "AEC version is too old (version unspecified). Minimum supported version is 1.1.1.")
endif()
if (AEC_VERSION VERSION_LESS 1.1.1)
message(FATAL_ERROR "AEC version is too old. Minimum supported version is 1.1.1. Found version: ${AEC_VERSION}")
endif()
# Optional dependency: dhskit
ecbuild_find_package( NAME dhskit VERSION 0.8.6 )
set(GRIBJUMP_HAVE_DHSKIT ${dhskit_FOUND})
endif()
# python api test are currently by default disabled because we cannot run them in the ci
ecbuild_add_option(
FEATURE PYTHON_API_TESTS
DEFAULT OFF
DESCRIPTION "Will execute python tests against pygribjump / libgribjump")
########################################################################################################################
# contents
include(compiler_warnings) # optionally handle compiler specific warnings
include(find_python_module)
set( gribjump_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src )
include_directories(
${AEC_INCLUDE_DIRS}
${gribjump_INCLUDE_DIRS}
${eckit_INCLUDE_DIRS}
)
set_directory_properties( PROPERTIES COMPILE_DEFINITIONS "${ECKIT_DEFINITIONS};${ECCODES_DEFINITIONS}" )
get_directory_property( gribjump_DEFINITIONS COMPILE_DEFINITIONS )
### source files
add_subdirectory( src )
if (HAVE_GRIBJUMP_LOCAL_EXTRACT)
add_subdirectory( tests )
endif()
if(HAVE_PYTHON_API_TESTS)
ecbuild_find_package( NAME Python
VERSION 3.10
COMPONENTS Interpreter
REQUIRED )
find_python_module(cffi)
find_python_module(numpy)
find_python_module(pytest)
find_python_module(setuptools)
find_python_module(findlibs)
# Depending on if gribjumps dependencies are installed or inside a build
# tree locations must be made known to fdb and eccodes.
# If this cmake file is not the top-level cmake file we deduce that this is
# a bundle build and all dependencies are inside a build tree.
# Otherwise it is expected that all dependencies reside in an install tree
get_property(is_subproject DIRECTORY PROPERTY PARENT_DIRECTORY)
if(is_subproject)
set(FDB5_DIR "${CMAKE_BINARY_DIR}")
# This is not required if eccodes is build with ENABLE_MEMFS=ON, but in
# that case the environment variable is ignored.
set(REDEFINED_ECCODES_DEFINITION_PATH
"${CMAKE_BINARY_DIR}/share/eccodes/definitions")
else()
set(REDEFINED_ECCODES_DEFINITION_PATH "")
set(FDB5_DIR "${fdb5_DIR}/../../..")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/run_pytest.sh.in
${CMAKE_CURRENT_BINARY_DIR}/run_pytest.sh
@ONLY
)
add_test(
NAME pygribjump_pytests
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_pytest.sh -vv -s
--basetemp=${CMAKE_CURRENT_BINARY_DIR}/pytest-out
)
endif()
########################################################################################################################
### finalize
ecbuild_install_project( NAME gribjump )
ecbuild_print_summary()