forked from NOAA-EMC/wgrib2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
173 lines (139 loc) · 5.54 KB
/
CMakeLists.txt
File metadata and controls
173 lines (139 loc) · 5.54 KB
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
# This is the main CMake build file for the wgrib2 project.
#
# Kyle Gerheiser, Edward Hartnett, Wesley Ebisuzaki, Alyson Stahl
cmake_minimum_required(VERSION 3.15)
# Read the current version number from file VERSION.
file(STRINGS "VERSION" pVersion)
# Set up project with version number from VERSION file.
project(wgrib2 VERSION ${pVersion} LANGUAGES C)
# Provide install directories according to GNU standards.
include(GNUInstallDirs)
# Find CMake code we need.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Handle user build options.
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
option(USE_NETCDF "Use NetCDF" off)
option(USE_REGEX "Use Regex?" on)
option(USE_TIGGE "Use tigge?" on)
option(USE_MYSQL "Use MySQL?" off)
option(USE_IPOLATES "Use Ipolates" off)
option(USE_UDF "Use UDF?" off)
option(USE_OPENMP "Use OpenMP?" off)
option(USE_PROJ4 "Use Proj4?" off)
option(USE_WMO_VALIDATION "Use WMO Validation?" off)
option(DISABLE_TIMEZONE "Disable posix Timezone?" off)
option(DISABLE_ALARM "Disable Alarm?" off)
set(USE_NAMES "NCEP")
option(USE_G2CLIB_HIGH "Use g2c high-level decoder (-g2clib 2)?" off)
option(USE_G2CLIB_LOW "Use g2c low-level decoders (png,jpeg2000)?" off)
option(USE_AEC "Use AEC to enable encoding/decoding of GRIB2 data with CCSDS packing (packing type 42)." off)
option(BUILD_EXTRA "Build user-contributed code" OFF)
option(FTP_TEST_FILES "Fetch and test with files on FTP site." OFF)
option(FTP_LARGE_TEST_FILES "Fetch and test with very large files on FTP site." OFF)
option(FTP_EXTRA_TEST_FILES "Fetch even more large files from FTP and test them." OFF)
# MAKE_FTN_API should only be on when building library
option(MAKE_FTN_API "add ftn api?" off)
option(DISABLE_STAT "disable posix feature" off)
set(BUILD_COMMENTS "stock build")
option(BUILD_LIB "Build wgrib2 library?" on)
# if BUILD_LIB, then code is compiled as relocatable
option(BUILD_SHARED_LIB "Build shared library?" on)
# To create libwgrib2.so for python, you have to build with BUILD_SHARED_LIB off
# and manually create libwgrib2.so from the needed *.a files
option(BUILD_WGRIB "Build wgrib code?" off)
if (MAKE_FTN_API OR USE_IPOLATES)
enable_language(Fortran)
endif()
# Developers can use this option to specify a local directory which
# holds the test files. They will be copied instead of fetching the
# files via FTP.
SET(TEST_FILE_DIR "." CACHE STRING "Check this directory for test files before using FTP.")
message(STATUS "Finding test data files in directory ${TEST_FILE_DIR}.")
# Set default install path if not provided.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"${CMAKE_BINARY_DIR}/install"
CACHE PATH "default install path" FORCE)
endif()
if(USE_G2CLIB_HIGH AND NOT USE_G2CLIB_LOW)
message(FATAL_ERROR "USE_G2CLIB_LOW must be on when USE_G2CLIB_HIGH")
endif()
if (BUILD_SHARED_LIB AND NOT BUILD_LIB)
message(FATAL_ERROR "BUILD_SHARED_LIB is on but BUILD_LIB is off")
endif()
if(MAKE_FTN_API AND NOT BUILD_LIB)
message(FATAL_ERROR "MAKE_FTN_API should only be on when building library")
endif()
# If user wants to use NCEPLIBS-ip, find it and the sp library.
message(STATUS "Checking if the user want to use NCEPLIBS-ip...")
if(USE_IPOLATES)
find_package(ip 5.2.0 CONFIG REQUIRED)
list(APPEND definitions_list -DIPOLATES_LIB="ipolates_lib_d")
endif()
message(STATUS "Checking if the user want to use NetCDF...")
if(USE_NETCDF)
find_package(NetCDF MODULE REQUIRED COMPONENTS C)
endif()
if(USE_G2CLIB_HIGH OR USE_G2CLIB_LOW)
find_package(g2c 2.2.0 CONFIG REQUIRED)
endif()
message(STATUS "Checking if the user want to use OpenMP...")
if(USE_OPENMP)
find_package(OpenMP REQUIRED COMPONENTS C)
endif()
# Find required packages to use AEC
message(STATUS "Checking if the user wants to use AEC...")
if(USE_AEC)
find_package(libaec 1.0.6 REQUIRED)
endif()
# write config.h
message(STATUS "Writing config.h...")
configure_file("${PROJECT_SOURCE_DIR}/wgrib2/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
message(STATUS "Adding wgrib2, aux_probs subdirectories...")
if (BUILD_EXTRA)
add_subdirectory(extra)
endif()
add_subdirectory(wgrib2)
add_subdirectory(aux_progs)
if(BUILD_LIB)
message(STATUS "Adding wgrib2 library build...")
### Package config
include(CMakePackageConfigHelpers)
set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
# No need for config file if library isn't built
export(EXPORT wgrib2_exports
NAMESPACE wgrib2::
FILE wgrib2-targets.cmake)
configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION})
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})
install(EXPORT wgrib2_exports
NAMESPACE wgrib2::
FILE wgrib2-targets.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})
endif()
if (BUILD_WGRIB)
add_subdirectory(wgrib)
endif()
# to set compiler flags
# see wgrib2/CMakeLists.txt
#
# Turn on unit testing.
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
# Determine whether or not to generate documentation.
if(ENABLE_DOCS)
find_package(Doxygen REQUIRED)
add_subdirectory(docs)
endif()