location of hdf5-config in hdf5 1.8.21

Previously, we have been using hdf5 version 1.8.17 with CMake. After building and installing hdf5, the file hdf5-config.cmake was located in
and I was able to locate the package just fine when calling find_package(HDF5 CONFIG).

But now, in version 1.8.21, the file is located instead in:

However, this is against CMake convention, and CMake does not pick up the file when calling find_package(HDF5 CONFIG).

An exhaustive list, where CMake looks for the config files can be found here https://cmake.org/cmake/help/v3.15/command/find_package.html?highlight=i#search-procedure, but <prefix>/cmake/<name>* is not one of them.

Can you please follow CMake convention here, so that the package is locatable again, without explicitly setting a HDF5_DIR variable, pointing to the location?

It was changed because the someone with CMake expertise explained that the find search is expecting the subfolders in share/cmake.

Ok, sorry I was not 100% clear in the previous post.
Actually, yes, on Linux it will be installed to <prefix>/share/cmake/hdf5 which is in the CMake search path, as per documentation.
But this problem is regarding Windows, where the files are installed to <prefix>/cmake/hdf5, which is NOT in the CMake search path.

Take a look at config\cmake_ext_mod\HDFMacros.cmake, ${package_prefix}_INSTALL_CMAKE_DIR is set to share/cmake for non Windows, and just cmake for Windows. Afterwards appending hdf5 to it creates the problem that I described on Windows.

So to sum it up:
The folder share/cmake/hdf5 (used on Unix) is ok but cmake/hdf5 (used on Windows) is not.
Then I’d recommend instead to also use share/cmake/hdf5 on Windows. Although it’s not the covention for Windows, CMake will at least still look in this folder. Also the code changes will be minimal (just HDFMacros.cmake).

Please note, the search procedure and paths are well documented for both
Unix and Windows:


<prefix>/                                                       (W)
<prefix>/(cmake|CMake)/                                         (W)
<prefix>/<name>*/                                               (W)
<prefix>/<name>*/(cmake|CMake)/                                 (W)
<prefix>/(lib/<arch>|lib*|share)/cmake/<name>*/                 (U)
<prefix>/(lib/<arch>|lib*|share)/<name>*/                       (U)
<prefix>/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/         (U)
<prefix>/<name>*/(lib/<arch>|lib*|share)/cmake/<name>*/         (W/U)
<prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/               (W/U)
<prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/ (W/U)

Each of them with a (W) will work for Windows, which includes


but not


which seams to be a little mix up. Please do not make up your non-standard own one :wink: so


is not a good choice for Windows.

I guess the difference between Windows and Linux is, that usually on Windows, <prefix> will be C:\Program Files where then you have a hdf5 directory, and in there then the covention.
So, if you did package hdf5, and then install it to the Program Files folder, THEN your path would be <prefix>/hdf5/share/cmake/hdf5 which is marked as (W/U).
But really I don’t care which convention is used as long as it will work out of the box.

But anyways, how would you recommend that this issue be fixed? Right now I am patching the sources for 1.8.21 manually, but I’d appreciate a solution for Windows.
I am also willing to check if this applies to the newest 1.10 release, too.

Hi @byrn, this still seems an issue today, at least with 1.10.6 release. It bites us over and over again. Any plans on fixing it?

I thought we have changed things for new releases since then, but I guess we did not get the windows locations changed. The problem is that this has been use for so long that a drastic change might cause problems.
I understand the issue, however from that same URL for the search procedure is the following statement:
This is merely a convention, so all (W) and (U) directories are still searched on all platforms.


Hi @byrn,

but the real problem is, that the file is not located in any of the located directories, as @a.huebl pointed out. Please read the directories carefully.

So It’s currently located in


but that is not any of the paths listed above!
If you build and install with CMake, other projects are not able to locate hdf5.

The following would all be ok:


I can double check with the newest 1.12. release, but it would be perfect if it worked also with the 1.10.x releases.

Best, Kerstin

I will attempt to fix this before the next release.
One question - is it just windows or are the linux builds also wrong?


Another question/response - I believe this was altered in the current development branches such that from a github issue, the directory would be /share/cmake/hdf5-*.cmake on all platforms. This path I believe is in the list;
<prefix>/(lib/<arch>|lib*|share)/cmake/<name>*/ (U)
which is searched on windows according to CMake documentation.

I believe that the “hdf5” extra path was left on in error during the latest round of commits and merges.


Yes, only Windows builds were broken, Linux builds were fine.

The path which you posted should now be fine :+1:

Does this only apply for the 1.12.x release line, or also 1.10.x?
Thanks, Kerstin

I created PRs for all development branches. I think it will be in the 1.10.8 release as well.