FindHDF5 fails on MSVC, despite existing package configuration from HDF5
I have an issue that may be related to #18560 (closed), but happens only on MSVC. The same configuration works in our CI system on many flavors of Linux and MacOSX (with as similar a setup as the different platforms support).
tl;dr: FindHDF5 does not detect a static build of HDF5 on MSVC 2015 and MSVC 2017, even though HDF5's package configuration script hdf5-config.cmake
is present. My expectation is that with hdf5-config.cmake
present, HDF5 detection should "just work".
I build HDF5 1.10.4 (current latest) on MSVC 2015 and 2017 using cmake 3.13.4 (current latest). I build components C
, CXX
and HL
, static, without threadsafe, and without parallel. Then I install to D:/Debug/
. I checked that HDF5 correctly installs hdf5-config.cmake
in D:/Debug/lib/cmake/hdf5/
. There are no compiler wrappers installed, but I assume they are not supported on MSVC(?). There is no other hdf5 on my system.
When I try to build a library that depends on HDF5, it is not detected. To build my dependent library, I configure cmake 3.13.4 with CMAKE_PREFIX_PATH
, CMAKE_INSTALL_PREFIX
and HDF5_ROOT
all pointing to D:/Debug
where HDF5 is installed. Furthermore I set HDF5_USE_STATIC_LIBS=ON
to hint towards the static build, and I set -DHDF5_FIND_DEBUG="ON"
but it only prints the information show below.
find_package(HDF5 QUIET REQUIRED)
prints:
-- Found HDF5 at D:/Debug/lib/cmake/hdf5 via NO_MODULE. Now trying to extract locations etc.
CMake Error at D:/Tools/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find HDF5 (missing: HDF5_LIBRARIES) (found version "1.10.4")
Call Stack (most recent call first):
D:/Tools/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
D:/Tools/share/cmake-3.13/Modules/FindHDF5.cmake:931 (find_package_handle_standard_args)
CMakeLists.txt:38 (find_package)
I tried also latest FindHDF5.cmake
from https://github.com/Kitware/CMake/blob/master/Modules/FindHDF5.cmake rev d3d9e6b7 but I get the same result.