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
|
diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
index d06a276..5d97fd3 100644
--- a/cmake/dependencies.cmake
+++ b/cmake/dependencies.cmake
@@ -134,7 +134,22 @@ if(USE_HDF5)
#####
# First, find the C and HL libraries.
#####
- find_package(HDF5 COMPONENTS C HL REQUIRED)
+ find_package(HDF5 NAMES hdf5 CONFIG COMPONENTS C HL REQUIRED)
+ if(TARGET HDF5::HDF5)
+ # pass
+ elseif(TARGET hdf5::hdf5-shared)
+ add_library(HDF5::HDF5 ALIAS hdf5::hdf5-shared)
+ elseif(TARGET hdf5::hdf5-static)
+ add_library(HDF5::HDF5 ALIAS hdf5::hdf5-static)
+ endif()
+ if(TARGET hdf5::hdf5_hl)
+ # pass
+ elseif(TARGET hdf5::hdf5_hl-shared)
+ add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-shared)
+ elseif(TARGET hdf5::hdf5_hl-static)
+ add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-static)
+ endif()
+ set(HDF5_IS_PARALLEL "${HDF5_ENABLE_PARALLEL}")
message(STATUS "Found HDF5 version: ${HDF5_VERSION}")
if(${HDF5_VERSION} VERSION_LESS ${HDF5_VERSION_REQUIRED})
@@ -144,7 +159,6 @@ if(USE_HDF5)
message(STATUS "Using HDF5 include dir: ${HDF5_INCLUDE_DIRS}")
target_link_libraries(netcdf
PRIVATE
- HDF5::HDF5
)
find_package(Threads)
@@ -244,10 +258,10 @@ if( NETCDF_ENABLE_DAP2 OR NETCDF_ENABLE_DAP4 OR NETCDF_ENABLE_BYTERANGE_SUPPORT
# ${CURL_INCLUDE_DIRS}
#)
if(CURL_FOUND)
+ set(CURL_LIBRARIES "")
set(FOUND_CURL TRUE)
target_link_libraries(netcdf
PRIVATE
- CURL::libcurl
)
else()
set(FOUND_CURL FALSE)
@@ -345,6 +359,10 @@ if(NOT WIN32)
set(HAVE_LIBM "")
endif()
else(NOT HAVE_LIBM)
+ find_library(HAVE_LIBM_M NAMES m)
+ if(HAVE_LIBM STREQUAL HAVE_LIBM_M)
+ set(HAVE_LIBM m)
+ endif()
message(STATUS "Found Math library: ${HAVE_LIBM}")
endif()
endif()
@@ -354,6 +372,7 @@ endif()
################################
# See if we have zlib
find_package(ZLIB)
+set(ZLIB_LIBRARY ZLIB::ZLIB)
# Define a test flag for have zlib library
if(ZLIB_FOUND)
@@ -371,18 +390,25 @@ endif()
################################
MESSAGE(STATUS "Checking for filter libraries")
IF (NETCDF_ENABLE_FILTER_SZIP)
- find_package(Szip)
+ find_package(libaec CONFIG REQUIRED)
+ set(Szip_FOUND 1)
+ set(Szip_LIBRARY libaec::sz)
+ set(Szip_LIBRARIES "${Szip_LIBRARY}")
elseif(NETCDF_ENABLE_NCZARR)
- find_package(Szip)
+ # purely transitive
endif()
IF (NETCDF_ENABLE_FILTER_BZ2)
- find_package(Bz2)
+ find_package(BZip2 REQUIRED)
+ set(Bz2_FOUND 1)
+ set(Bz2_LIBRARIES BZip2::BZip2)
+ set(Bzip2_LIBRARIES "${Bz2_LIBRARIES}")
endif()
IF (NETCDF_ENABLE_FILTER_BLOSC)
find_package(Blosc)
endif()
IF (NETCDF_ENABLE_FILTER_ZSTD)
- find_package(Zstd)
+ find_package(Zstd NAMES zstd REQUIRED)
+ set(Zstd_LIBRARIES zstd::libzstd)
endif()
# Accumulate standard filters
@@ -412,7 +438,8 @@ endif()
set(STD_FILTERS "${STD_FILTERS}${FOUND_STD_FILTERS}")
IF (NETCDF_ENABLE_NCZARR_ZIP)
- find_package(Zip)
+ find_package(Zip NAMES libzip REQUIRED)
+ set(Zip_LIBRARIES libzip::zip)
if(Zip_FOUND)
target_include_directories(netcdf
PRIVATE
diff --git a/libdispatch/CMakeLists.txt b/libdispatch/CMakeLists.txt
index 0f5d66d..13ef7ca 100644
--- a/libdispatch/CMakeLists.txt
+++ b/libdispatch/CMakeLists.txt
@@ -14,6 +14,10 @@ target_sources(dispatch
ncproplist.c
)
+if(NETCDF_ENABLE_DAP2 OR NETCDF_ENABLE_DAP4 OR NETCDF_ENABLE_BYTERANGE)
+ target_link_libraries(dispatch PRIVATE CURL::libcurl)
+endif()
+
if (NETCDF_ENABLE_DLL)
target_compile_definitions(dispatch PRIVATE DLL_NETCDF DLL_EXPORT)
endif()
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index cc482d5..5f263c5 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -43,7 +43,6 @@ if(USE_HDF4)
endif()
if(FOUND_CURL)
- target_link_libraries(netcdf PRIVATE CURL::libcurl)
endif()
if(NETCDF_ENABLE_DAP2)
@@ -60,6 +59,7 @@ if(NETCDF_ENABLE_DAP4)
$<TARGET_OBJECTS:dap4>
$<TARGET_OBJECTS:ncxml>
)
+ list(APPEND EXTRA_DEPS tinyxml2::tinyxml2)
endif()
if(NETCDF_ENABLE_NCZARR)
@@ -74,6 +74,7 @@ if(NETCDF_ENABLE_S3_INTERNAL)
PRIVATE
$<TARGET_OBJECTS:ncxml>
)
+ list(APPEND EXTRA_DEPS tinyxml2::tinyxml2)
endif()
if(NETCDF_ENABLE_PLUGINS)
@@ -185,6 +186,14 @@ endif()
if(TLL_LIBS)
list(REMOVE_DUPLICATES TLL_LIBS)
+ # Plugins only
+ list(REMOVE_ITEM TLL_LIBS
+ ${Blosc_LIBRARIES}
+ ${Bz2_LIBRARIES}
+ ${Szip_LIBRARIES}
+ ${ZLIB_LIBRARY}
+ ${Zstd_LIBRARIES}
+ )
endif()
target_link_libraries(netcdf PRIVATE ${TLL_LIBS})
diff --git a/libncxml/CMakeLists.txt b/libncxml/CMakeLists.txt
index b8fa4b2..65f1c18 100644
--- a/libncxml/CMakeLists.txt
+++ b/libncxml/CMakeLists.txt
@@ -1,7 +1,7 @@
if(HAVE_LIBXML2)
set(libncxml_SOURCES ncxml_xml2.c)
else()
- set(libncxml_SOURCES ncxml_tinyxml2.cpp tinyxml2.cpp tinyxml2.h)
+ set(libncxml_SOURCES ncxml_tinyxml2.cpp)
endif()
add_library(ncxml OBJECT ${libncxml_SOURCES})
@@ -13,6 +13,8 @@ if(HAVE_LIBXML2)
${LIBXML2_INCLUDE_DIRS}
)
else()
+ find_package(tinyxml2 CONFIG REQUIRED GLOBAL)
+ target_link_libraries(ncxml PRIVATE $<COMPILE_ONLY:tinyxml2::tinyxml2>)
target_include_directories(ncxml
PUBLIC
./include
diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in
index 987b2ad..0dfda8e 100644
--- a/netCDFConfig.cmake.in
+++ b/netCDFConfig.cmake.in
@@ -4,6 +4,17 @@
#
@PACKAGE_INIT@
+if(NOT "@BUILD_SHARED_LIBS@")
+ include(CMakeFindDependencyMacro)
+ find_dependency(tinyxml2 CONFIG)
+ if("@FOUND_CURL@")
+ find_dependency(CURL)
+ endif()
+ if("@NETCDF_ENABLE_NCZARR_ZIP@")
+ find_dependency(libzip CONFIG)
+ endif()
+endif()
+
set(NetCDFVersion "@PACKAGE_VERSION@")
set_and_check(netCDF_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
set_and_check(netCDF_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")
@@ -42,7 +53,7 @@ set(netCDF_HAS_DISKLESS @HAS_DISKLESS@)
set(netCDF_HAS_MMAP @HAS_MMAP@)
if (netCDF_HAS_HDF4 OR netCDF_HAS_HDF5)
include(CMakeFindDependencyMacro)
- find_dependency(HDF5)
+ find_dependency(hdf5 CONFIG)
endif ()
if (@HAS_PARALLEL@)
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index fbaeb21..8cdb5d4 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -4,7 +4,7 @@
# University Corporation for Atmospheric Research/Unidata.
# See netcdf-c/COPYRIGHT file for more info.
-set(CMAKE_BUILD_TYPE "")
+set(ALL_TLL_LIBS ${HAVE_LIBM})
if(WIN32)
set(PLUGINEXT "dll")
@@ -86,10 +86,13 @@ buildplugin(h5unknown "h5unknown")
buildplugin(h5shuffle "h5shuffle")
buildplugin(h5fletcher32 "h5fletcher32")
-buildplugin(h5deflate "h5deflate")
+buildplugin(h5deflate "h5deflate" ZLIB::ZLIB)
buildplugin(nczmisc "zmisc")
buildplugin(nczhdf5filters "zhdf5filters" netcdf)
+if(HAVE_SZ)
+ target_link_libraries(nczhdf5filters PRIVATE ${Szip_LIBRARIES})
+endif()
if(NETCDF_ENABLE_BLOSC)
set(h5blosc_SOURCES H5Zblosc.c)
|