netcdf-c: cmake exported target uses undefined hdf5::hdf5 imported target

on mingw (win32), compiling netcdf with cmake, with a cmake-compiled hdf5 using its exported target (module mode, not config mode), results in an installed netcdf-targets.cmake that contains the hdf5::hdf5 target (and hdf5::hdf5_hl) in the INTERFACE_LINK_LIBRARIES properties.

But then, when using netcdf in module mode (with find_package(netCDF)) these hdf5 targets are undefined (the hdf5 cmake config is not included), and cmake is not happy:

-- Configuring done
CMake Error at CMake/vtkModule.cmake:2968 (add_library):
  Target "IONetCDF" links to target "hdf5::hdf5_hl-shared" but the target was not found

We first encountered this bug in vtk: https://gitlab.kitware.com/vtk/vtk/issues/17637

A workaround is to provide manually hdf5 paths when configuring netcdf, doing so results in actual library paths being written to the exported targets file instead of hdf5 targets.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 17 (16 by maintainers)

Commits related to this issue

Most upvoted comments

@WardF, yes, I think the updates we’ve added may fix this. I’ll have to check

Note that a similar issue is with missing a dependency on MPI as well. This commit: https://github.com/Unidata/netcdf-c/commit/bc2a3babf9cbe80fa7ae3dec5d7622594a7ae51e introduces a call to find_package(MPI) on MSVC but surely this should be done for all platforms that use mpi as ncdispatch.h includes mpi.h if HDF5_PARALLEL or USE_PNETCDF is defined.