diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index d06a276..b7ada29 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -134,7 +134,14 @@ if(USE_HDF5) ##### # First, find the C and HL libraries. ##### - find_package(HDF5 COMPONENTS C HL REQUIRED) + find_package(HDF5 NO_MODULE COMPONENTS C HL REQUIRED) + if(TARGET hdf5::hdf5-static) + add_library(HDF5::HDF5 ALIAS hdf5::hdf5-static) + add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-static) + else() + add_library(HDF5::HDF5 ALIAS hdf5::hdf5-shared) + add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-shared) + endif() message(STATUS "Found HDF5 version: ${HDF5_VERSION}") if(${HDF5_VERSION} VERSION_LESS ${HDF5_VERSION_REQUIRED}) @@ -173,6 +180,13 @@ if(USE_HDF5) message(STATUS "HDF5 has zlib.") endif() + if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${ZLIB_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" + ) + endif() # Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip library. check_hdf5_feature(HAVE_H5Z_SZIP H5_HAVE_FILTER_SZIP) @@ -466,8 +480,8 @@ endif() ################################ # see if we have libxml2 if(NETCDF_ENABLE_LIBXML2) - find_package(LibXml2) - if(LibXml2_FOUND) + find_package(libxml2 CONFIG REQUIRED) + if(TARGET LibXml2::LibXml2) set(HAVE_LIBXML2 TRUE) target_include_directories(netcdf PRIVATE diff --git a/libdispatch/CMakeLists.txt b/libdispatch/CMakeLists.txt index 0f5d66d..2f65518 100644 --- a/libdispatch/CMakeLists.txt +++ b/libdispatch/CMakeLists.txt @@ -14,6 +14,8 @@ target_sources(dispatch ncproplist.c ) +target_link_libraries(dispatch PUBLIC CURL::libcurl ${CURL_LIBRARIES}) + if (NETCDF_ENABLE_DLL) target_compile_definitions(dispatch PRIVATE DLL_NETCDF DLL_EXPORT) endif() diff --git a/libhdf5/CMakeLists.txt b/libhdf5/CMakeLists.txt index 9281a25..61198b2 100644 --- a/libhdf5/CMakeLists.txt +++ b/libhdf5/CMakeLists.txt @@ -17,6 +17,8 @@ target_sources(netcdfhdf5 PRIVATE hdf5set_format_compatibility.c hdf5debug.c ) +target_link_libraries(netcdfhdf5 PUBLIC CURL::libcurl) + if (NETCDF_ENABLE_DLL) target_compile_definitions(netcdfhdf5 PRIVATE DLL_NETCDF DLL_EXPORT) endif() diff --git a/libncxml/CMakeLists.txt b/libncxml/CMakeLists.txt index b8fa4b2..f881a92 100644 --- a/libncxml/CMakeLists.txt +++ b/libncxml/CMakeLists.txt @@ -12,6 +12,7 @@ if(HAVE_LIBXML2) PRIVATE ${LIBXML2_INCLUDE_DIRS} ) +target_link_libraries(ncxml PUBLIC LibXml2::LibXml2) else() target_include_directories(ncxml PUBLIC diff --git a/libncxml/ncxml_xml2.c b/libncxml/ncxml_xml2.c index 12132a7..7da27d5 100644 --- a/libncxml/ncxml_xml2.c +++ b/libncxml/ncxml_xml2.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include "ncxml.h" diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in index 987b2ad..32eba6d 100644 --- a/netCDFConfig.cmake.in +++ b/netCDFConfig.cmake.in @@ -40,9 +40,14 @@ set(netCDF_HAS_DAP2 @HAS_DAP2@) set(netCDF_HAS_DAP4 @HAS_DAP4@) set(netCDF_HAS_DISKLESS @HAS_DISKLESS@) set(netCDF_HAS_MMAP @HAS_MMAP@) + + +include(CMakeFindDependencyMacro) +find_dependency(CURL) + 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..740bdb1 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -58,7 +58,7 @@ macro(buildplugin TARGET TARGETLIB) set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_NAME ${MANGLELIB}) set_target_properties(${TARGET} PROPERTIES PREFIX "") # Critical that this be set to "" set_target_properties(${TARGET} PROPERTIES SUFFIX ".${PLUGINEXT}") - target_link_libraries(${TARGET} PUBLIC ${ALL_TLL_LIBS};${ARGN}) + target_link_libraries(${TARGET} PUBLIC ${ALL_TLL_LIBS};${ARGN};ZLIB::ZLIB) if(MSVC) target_compile_options(${TARGET} PRIVATE /Zi) # Tell linker to include symbol data