FindHDF5.cmake needs update for HDF5 1.10.6
This issue and patch fix two distinct issues with HDF5 1.10.6, particularly on Windows but also for non-Windows. I would be happy to turn this into an MR, but would like quality feedback.
With this patch, the following work for me with CMake 3.16.2:
- MSYS2, HDF5 1.10.5 (broken previously, fixed by this patch)
- Ubuntu 18.04, HDF5 1.10.4 (worked previously)
- Intel Fortran 19.1/2010, Windows 10, HDF5 1.10.6 (didn't work till this patch) using HDF5 1.10.6 binary download
Fortran_HL filename change
HDF5 1.10.6 (released Dec 2019) appears to have changed the naming convention for a Fortran library to be consistent with the other languages.
- old:
hdf5hl_fortran.
- new:
hdf5_hl_fortran.
MSYS2 / Intel Fortran Windows include/{shared,static}
In general (and with previous HDF5 1.10 releases) MSYS2 needs to have included include/static
or include/shared
.
Intel Fortran on Windows specifically needs include/shared
Notes
Intel Fortran 19.1/2020 on Windows works with HDF5 like:
ifort -I"C:\Program Files\HDF_Group\HDF5\1.10.6\include\shared" test_minimal.f90 "C:\Program Files\HDF_Group\HDF5\1.10.6\lib\hdf5_fortran.lib" "C:\Program Files\HDF_Group\HDF5\1.10.6\lib\hdf5_hl_fortran.lib" "C:\Program Files\HDF_Group\HDF5\1.10.6\lib\hdf5.lib" "C:\Program Files\HDF_Group\HDF5\1.10.6\lib\szip.lib" "C:\Program Files\HDF_Group\HDF5\1.10.6\lib\zlib.lib"
I have not tried prior HDF5 releases with Intel Fortran to see if this is a new or old issue.
For this case, if you use include/static
you will get errors like
error LNK2019: unresolved external symbol H5GLOBAL_mp_H5F_ACC_TRUNC_F referenced in function MAIN__
Example build / test
To build using HDF5 with Intel Fortran on Windows:
cmake -B build -DHDF5_ROOT="C:\Program Files\HDF_Group\HDF5\1.10.6"
We have found on Windows that the pkg-config files from HDF Group are goofed up, specifically for MSYS2. So in our CMakeLists.txt:
if(WIN32)
set(HDF5_NO_FIND_PACKAGE_CONFIG_FILE true)
endif()
and then for the Ctest executables to be able to find the DLL (no Rpath on Windows) in your CMakeLists.txt, assuming a test named "Minimal"
set_tests_properties(Minimal PROPERTIES ENVIRONMENT "PATH=${HDF5_ROOT}/bin;$ENV{PATH}")
There are no compiler wrappers for Windows e.g. h5fc
is not present