Can't perform find_package(hdf5 REQUIRED) in CMake


I’m trying to use HDF5 as an external project while CMake superbuild (inside Slicer 3D application). My test project where you can see the CMake files is located here.
The problem is that after CMake builds HDF5 I cannot perform find_package(hdf5 REQUIRED). This command gives me error:

CMake Warning (dev) at C:/Qt/Tools/CMake_64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:424 (message):
The package name passed to find_package_handle_standard_args (HDF5) does
not match the name of the calling package (hdf5). This can lead to
problems in calling code that expects find_package result variables
_(e.g., FOUND) to follow a certain pattern.
Call Stack (most recent call first):
C:/Qt/Tools/CMake_64/share/cmake-3.19/Modules/FindHDF5.cmake:975 (find_package_handle_standard_args)
C:/S/d/VTK/CMake/FindHDF5.cmake:9 (include)
KKK/CMakeLists.txt:10 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.

– Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS) (found version “”)

If I change lower case find_package(hdf5 REQUIRED) to upper case find_package(HDF5 REQUIRED) then I get the following error:

CMake Error at C:/Qt/Tools/CMake_64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
_ Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS) (found_
_ version “”)_

I need help to overcome this problem

Windows 10 x64, MSVC 2019 x64, HDF5 git-tag hdf5-1_12_0 and hdf-1_10_7, CMAKE 3.13.4

I think the main reason is that hdf5-config.cmake stores wrong information about where hdf5 is located.
The command find_package(hdf5 REQUIRED CONFIG) gives me error:
CMake Error at C:/S/extensions/Proba_fixed/Proba-build/hdf5-build/hdf5-config.cmake:25 (message):
File or directory C:/S/extensions/Proba_fixed/bin referenced by variable HDF5_TOOLS_DIR does not exist !

But hdf5 is build in here C:\S\extensions\Proba_fixed\Proba-build and the bin folder lives there: C:\S\extensions\Proba_fixed\Proba-build\bin

Could you try a development build of hdf5, a recent change moved where the hdf5-config files are located on windows. Any of the branches from git should be sufficient for the test.


Thank you for hint

I’m trying to build dev branch but whenI build it I always get the error:
fatal error C1083: Cannot open include file: ‘H5version.h’: No such file or directory

Can’t understand how to overcome this.

Windows 10 x64, CMake 3.19.0, MSVC 2019 x64 v142

Sorry, I forgot, dev branch requires the HDF5_GENERATE_HEADERS to be ON. release branches do not need this.


It seems that HDF5_GENERATE_HEADERS were ON by default but I got this error.
I’m gonna turn ON/OFF and will report

You can check the config/cmake/cacheinit.cmake file for the settings we use in our daily tests. Might be some clues.


thank you

It seems that after I downloaded Perl the HDF5-dev build is fine.
But I still get error when I try to compile HDF5 as an external package:

File or directory C:/S/extensions/bin referenced by variable HDF5_TOOLS_DIR does not exist !

It is strange that it used to be C:/S/extensions/Proba_fixed/bin but now the path is C:/S/extensions/bin

In my ExternalProject_Add(...) I have:
GIT_TAG "develop"
I think that is correct to force CMake to build HDF5-dev branch?

      # Compiler settings
      # Output directories
      # Install directories
      -DCMAKE_INSTALL_LIBDIR:STRING=${Slicer_INSTALL_THIRDPARTY_LIB_DIR} # Skip default initialization by GNUInstallDirs CMake module
      # Options

You should be right. I think the problem is that hdf5-config.cmake is located in wrong directory (it is in C:/.../hdf5-build dir).

I just tried to move this file two folders down (in C:/.../hdf5-build/src/CMakeFiles dir) and the command find_package(hdf5 REQUIRED CONFIG PATHS "C:/S/extensions/Proba_fixed/Proba-build/hdf5-build/src") didn’t give me the mentionned error but I got another one:
CMake Error at C:/S/extensions/Proba_fixed/Proba-build/hdf5-build/src/CMakeFiles/hdf5-config.cmake:144 (include):
include could not find load file:

while hdf5_FOUND returns TRUE

I think I cannot solve this issue by myself