Issue when building hdf5 as submodule via `add_subdirectory`


I am trying to build HDF5 as part of my project, but using a git submodule (pointing to release 1.10.6) via a CMake add_subdirectory.
In general, this works fine, however when I try to link hdf5-static, I am getting a build error "H5pubconf.h": No such file or directory

The reason for this is, that in scr\CMakeLists.txt you have the follwing code (line 1073 - 1077) (

 target_include_directories (${HDF5_LIB_TARGET}

The problem here is, that when using hdf5 as part of the build, H5pubconf.h will be located inside ${HDF5_BINARY_DIR}, but this is added only as a PRIVATE requirement of target_include_directories, it needs to be either public, or both private and interface.
If you change the line starting with INTERFACE to the following code, the project builds fine:


Is this the correct way to create a bugreport? I’d be happy to make a pull request.


Looks reasonable.

Should this be added to all the libraries that create headers?



Yes, I would think so. If anyone using that library will (implicitly) include the generated headers, then yes, the line will have to be added for that library.