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 <prefix>/cmake/hdf5-config.cmake
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: <prefix>/cmake/hdf5/hdf5-config.cmake
However, this is against CMake convention, and CMake does not pick up the file when calling find_package(HDF5 CONFIG).
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?
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).
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.
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.”
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
<prefix>\cmake\hdf5\hdf5-config.cmake
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.
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.