|
| 1 | +diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake |
| 2 | +index d06a276..5d97fd3 100644 |
| 3 | +--- a/cmake/dependencies.cmake |
| 4 | ++++ b/cmake/dependencies.cmake |
| 5 | +@@ -134,7 +134,22 @@ if(USE_HDF5) |
| 6 | + ##### |
| 7 | + # First, find the C and HL libraries. |
| 8 | + ##### |
| 9 | +- find_package(HDF5 COMPONENTS C HL REQUIRED) |
| 10 | ++ find_package(HDF5 NAMES hdf5 CONFIG COMPONENTS C HL REQUIRED) |
| 11 | ++ if(TARGET HDF5::HDF5) |
| 12 | ++ # pass |
| 13 | ++ elseif(TARGET hdf5::hdf5-shared) |
| 14 | ++ add_library(HDF5::HDF5 ALIAS hdf5::hdf5-shared) |
| 15 | ++ elseif(TARGET hdf5::hdf5-static) |
| 16 | ++ add_library(HDF5::HDF5 ALIAS hdf5::hdf5-static) |
| 17 | ++ endif() |
| 18 | ++ if(TARGET hdf5::hdf5_hl) |
| 19 | ++ # pass |
| 20 | ++ elseif(TARGET hdf5::hdf5_hl-shared) |
| 21 | ++ add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-shared) |
| 22 | ++ elseif(TARGET hdf5::hdf5_hl-static) |
| 23 | ++ add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-static) |
| 24 | ++ endif() |
| 25 | ++ set(HDF5_IS_PARALLEL "${HDF5_ENABLE_PARALLEL}") |
| 26 | + |
| 27 | + message(STATUS "Found HDF5 version: ${HDF5_VERSION}") |
| 28 | + if(${HDF5_VERSION} VERSION_LESS ${HDF5_VERSION_REQUIRED}) |
| 29 | +@@ -144,7 +159,6 @@ if(USE_HDF5) |
| 30 | + message(STATUS "Using HDF5 include dir: ${HDF5_INCLUDE_DIRS}") |
| 31 | + target_link_libraries(netcdf |
| 32 | + PRIVATE |
| 33 | +- HDF5::HDF5 |
| 34 | + ) |
| 35 | + |
| 36 | + find_package(Threads) |
| 37 | +@@ -244,10 +258,10 @@ if( NETCDF_ENABLE_DAP2 OR NETCDF_ENABLE_DAP4 OR NETCDF_ENABLE_BYTERANGE_SUPPORT |
| 38 | + # ${CURL_INCLUDE_DIRS} |
| 39 | + #) |
| 40 | + if(CURL_FOUND) |
| 41 | ++ set(CURL_LIBRARIES "") |
| 42 | + set(FOUND_CURL TRUE) |
| 43 | + target_link_libraries(netcdf |
| 44 | + PRIVATE |
| 45 | +- CURL::libcurl |
| 46 | + ) |
| 47 | + else() |
| 48 | + set(FOUND_CURL FALSE) |
| 49 | +@@ -345,6 +359,10 @@ if(NOT WIN32) |
| 50 | + set(HAVE_LIBM "") |
| 51 | + endif() |
| 52 | + else(NOT HAVE_LIBM) |
| 53 | ++ find_library(HAVE_LIBM_M NAMES m) |
| 54 | ++ if(HAVE_LIBM STREQUAL HAVE_LIBM_M) |
| 55 | ++ set(HAVE_LIBM m) |
| 56 | ++ endif() |
| 57 | + message(STATUS "Found Math library: ${HAVE_LIBM}") |
| 58 | + endif() |
| 59 | + endif() |
| 60 | +@@ -354,6 +372,7 @@ endif() |
| 61 | + ################################ |
| 62 | + # See if we have zlib |
| 63 | + find_package(ZLIB) |
| 64 | ++set(ZLIB_LIBRARY ZLIB::ZLIB) |
| 65 | + |
| 66 | + # Define a test flag for have zlib library |
| 67 | + if(ZLIB_FOUND) |
| 68 | +@@ -371,18 +390,25 @@ endif() |
| 69 | + ################################ |
| 70 | + MESSAGE(STATUS "Checking for filter libraries") |
| 71 | + IF (NETCDF_ENABLE_FILTER_SZIP) |
| 72 | +- find_package(Szip) |
| 73 | ++ find_package(libaec CONFIG REQUIRED) |
| 74 | ++ set(Szip_FOUND 1) |
| 75 | ++ set(Szip_LIBRARY libaec::sz) |
| 76 | ++ set(Szip_LIBRARIES "${Szip_LIBRARY}") |
| 77 | + elseif(NETCDF_ENABLE_NCZARR) |
| 78 | +- find_package(Szip) |
| 79 | ++ # purely transitive |
| 80 | + endif() |
| 81 | + IF (NETCDF_ENABLE_FILTER_BZ2) |
| 82 | +- find_package(Bz2) |
| 83 | ++ find_package(BZip2 REQUIRED) |
| 84 | ++ set(Bz2_FOUND 1) |
| 85 | ++ set(Bz2_LIBRARIES BZip2::BZip2) |
| 86 | ++ set(Bzip2_LIBRARIES "${Bz2_LIBRARIES}") |
| 87 | + endif() |
| 88 | + IF (NETCDF_ENABLE_FILTER_BLOSC) |
| 89 | + find_package(Blosc) |
| 90 | + endif() |
| 91 | + IF (NETCDF_ENABLE_FILTER_ZSTD) |
| 92 | +- find_package(Zstd) |
| 93 | ++ find_package(Zstd NAMES zstd REQUIRED) |
| 94 | ++ set(Zstd_LIBRARIES zstd::libzstd) |
| 95 | + endif() |
| 96 | + |
| 97 | + # Accumulate standard filters |
| 98 | +@@ -412,7 +438,8 @@ endif() |
| 99 | + |
| 100 | + set(STD_FILTERS "${STD_FILTERS}${FOUND_STD_FILTERS}") |
| 101 | + IF (NETCDF_ENABLE_NCZARR_ZIP) |
| 102 | +- find_package(Zip) |
| 103 | ++ find_package(Zip NAMES libzip REQUIRED) |
| 104 | ++ set(Zip_LIBRARIES libzip::zip) |
| 105 | + if(Zip_FOUND) |
| 106 | + target_include_directories(netcdf |
| 107 | + PRIVATE |
| 108 | +diff --git a/libdispatch/CMakeLists.txt b/libdispatch/CMakeLists.txt |
| 109 | +index 0f5d66d..13ef7ca 100644 |
| 110 | +--- a/libdispatch/CMakeLists.txt |
| 111 | ++++ b/libdispatch/CMakeLists.txt |
| 112 | +@@ -14,6 +14,10 @@ target_sources(dispatch |
| 113 | + ncproplist.c |
| 114 | + ) |
| 115 | + |
| 116 | ++if(NETCDF_ENABLE_DAP2 OR NETCDF_ENABLE_DAP4 OR NETCDF_ENABLE_BYTERANGE) |
| 117 | ++ target_link_libraries(dispatch PRIVATE CURL::libcurl) |
| 118 | ++endif() |
| 119 | ++ |
| 120 | + if (NETCDF_ENABLE_DLL) |
| 121 | + target_compile_definitions(dispatch PRIVATE DLL_NETCDF DLL_EXPORT) |
| 122 | + endif() |
| 123 | +diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt |
| 124 | +index cc482d5..5f263c5 100644 |
| 125 | +--- a/liblib/CMakeLists.txt |
| 126 | ++++ b/liblib/CMakeLists.txt |
| 127 | +@@ -43,7 +43,6 @@ if(USE_HDF4) |
| 128 | + endif() |
| 129 | + |
| 130 | + if(FOUND_CURL) |
| 131 | +- target_link_libraries(netcdf PRIVATE CURL::libcurl) |
| 132 | + endif() |
| 133 | + |
| 134 | + if(NETCDF_ENABLE_DAP2) |
| 135 | +@@ -60,6 +59,7 @@ if(NETCDF_ENABLE_DAP4) |
| 136 | + $<TARGET_OBJECTS:dap4> |
| 137 | + $<TARGET_OBJECTS:ncxml> |
| 138 | + ) |
| 139 | ++ list(APPEND EXTRA_DEPS tinyxml2::tinyxml2) |
| 140 | + endif() |
| 141 | + |
| 142 | + if(NETCDF_ENABLE_NCZARR) |
| 143 | +@@ -74,6 +74,7 @@ if(NETCDF_ENABLE_S3_INTERNAL) |
| 144 | + PRIVATE |
| 145 | + $<TARGET_OBJECTS:ncxml> |
| 146 | + ) |
| 147 | ++ list(APPEND EXTRA_DEPS tinyxml2::tinyxml2) |
| 148 | + endif() |
| 149 | + |
| 150 | + if(NETCDF_ENABLE_PLUGINS) |
| 151 | +@@ -185,6 +186,14 @@ endif() |
| 152 | + |
| 153 | + if(TLL_LIBS) |
| 154 | + list(REMOVE_DUPLICATES TLL_LIBS) |
| 155 | ++ # Plugins only |
| 156 | ++ list(REMOVE_ITEM TLL_LIBS |
| 157 | ++ ${Blosc_LIBRARIES} |
| 158 | ++ ${Bz2_LIBRARIES} |
| 159 | ++ ${Szip_LIBRARIES} |
| 160 | ++ ${ZLIB_LIBRARY} |
| 161 | ++ ${Zstd_LIBRARIES} |
| 162 | ++ ) |
| 163 | + endif() |
| 164 | + |
| 165 | + target_link_libraries(netcdf PRIVATE ${TLL_LIBS}) |
| 166 | +diff --git a/libncxml/CMakeLists.txt b/libncxml/CMakeLists.txt |
| 167 | +index b8fa4b2..65f1c18 100644 |
| 168 | +--- a/libncxml/CMakeLists.txt |
| 169 | ++++ b/libncxml/CMakeLists.txt |
| 170 | +@@ -1,7 +1,7 @@ |
| 171 | + if(HAVE_LIBXML2) |
| 172 | + set(libncxml_SOURCES ncxml_xml2.c) |
| 173 | + else() |
| 174 | +- set(libncxml_SOURCES ncxml_tinyxml2.cpp tinyxml2.cpp tinyxml2.h) |
| 175 | ++ set(libncxml_SOURCES ncxml_tinyxml2.cpp) |
| 176 | + endif() |
| 177 | + |
| 178 | + add_library(ncxml OBJECT ${libncxml_SOURCES}) |
| 179 | +@@ -13,6 +13,8 @@ if(HAVE_LIBXML2) |
| 180 | + ${LIBXML2_INCLUDE_DIRS} |
| 181 | + ) |
| 182 | + else() |
| 183 | ++ find_package(tinyxml2 CONFIG REQUIRED GLOBAL) |
| 184 | ++ target_link_libraries(ncxml PRIVATE $<COMPILE_ONLY:tinyxml2::tinyxml2>) |
| 185 | + target_include_directories(ncxml |
| 186 | + PUBLIC |
| 187 | + ./include |
| 188 | +diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in |
| 189 | +index 987b2ad..0dfda8e 100644 |
| 190 | +--- a/netCDFConfig.cmake.in |
| 191 | ++++ b/netCDFConfig.cmake.in |
| 192 | +@@ -4,6 +4,17 @@ |
| 193 | + # |
| 194 | + @PACKAGE_INIT@ |
| 195 | + |
| 196 | ++if(NOT "@BUILD_SHARED_LIBS@") |
| 197 | ++ include(CMakeFindDependencyMacro) |
| 198 | ++ find_dependency(tinyxml2 CONFIG) |
| 199 | ++ if("@FOUND_CURL@") |
| 200 | ++ find_dependency(CURL) |
| 201 | ++ endif() |
| 202 | ++ if("@NETCDF_ENABLE_NCZARR_ZIP@") |
| 203 | ++ find_dependency(libzip CONFIG) |
| 204 | ++ endif() |
| 205 | ++endif() |
| 206 | ++ |
| 207 | + set(NetCDFVersion "@PACKAGE_VERSION@") |
| 208 | + set_and_check(netCDF_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") |
| 209 | + set_and_check(netCDF_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") |
| 210 | +@@ -42,7 +53,7 @@ set(netCDF_HAS_DISKLESS @HAS_DISKLESS@) |
| 211 | + set(netCDF_HAS_MMAP @HAS_MMAP@) |
| 212 | + if (netCDF_HAS_HDF4 OR netCDF_HAS_HDF5) |
| 213 | + include(CMakeFindDependencyMacro) |
| 214 | +- find_dependency(HDF5) |
| 215 | ++ find_dependency(hdf5 CONFIG) |
| 216 | + endif () |
| 217 | + |
| 218 | + if (@HAS_PARALLEL@) |
| 219 | +diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt |
| 220 | +index fbaeb21..8cdb5d4 100644 |
| 221 | +--- a/plugins/CMakeLists.txt |
| 222 | ++++ b/plugins/CMakeLists.txt |
| 223 | +@@ -4,7 +4,7 @@ |
| 224 | + # University Corporation for Atmospheric Research/Unidata. |
| 225 | + |
| 226 | + # See netcdf-c/COPYRIGHT file for more info. |
| 227 | +-set(CMAKE_BUILD_TYPE "") |
| 228 | ++set(ALL_TLL_LIBS ${HAVE_LIBM}) |
| 229 | + |
| 230 | + if(WIN32) |
| 231 | + set(PLUGINEXT "dll") |
| 232 | +@@ -86,10 +86,13 @@ buildplugin(h5unknown "h5unknown") |
| 233 | + |
| 234 | + buildplugin(h5shuffle "h5shuffle") |
| 235 | + buildplugin(h5fletcher32 "h5fletcher32") |
| 236 | +-buildplugin(h5deflate "h5deflate") |
| 237 | ++buildplugin(h5deflate "h5deflate" ZLIB::ZLIB) |
| 238 | + |
| 239 | + buildplugin(nczmisc "zmisc") |
| 240 | + buildplugin(nczhdf5filters "zhdf5filters" netcdf) |
| 241 | ++if(HAVE_SZ) |
| 242 | ++ target_link_libraries(nczhdf5filters PRIVATE ${Szip_LIBRARIES}) |
| 243 | ++endif() |
| 244 | + |
| 245 | + if(NETCDF_ENABLE_BLOSC) |
| 246 | + set(h5blosc_SOURCES H5Zblosc.c) |
0 commit comments