FindHDF5 should include HL libraries/targets in HDF5::HDF5 target
This may be due to unclear documentation, but the behavior is not intuitive. According to the documentation for FindHDF5.cmake
:
With all components enabled, the following targets will be defined:
``HDF5::HDF5``
All detected ``HDF5_LIBRARIES``.
However, if a HL component is requested, e.g.
find_package(HDF5 COMPONENTS C HL)
Then HDF5::HDF5
does not provide properties for the HL libs. These must be used explicitly:
target_link_libraries(myApp hdf5::hdf5 hdf5::hdf5_hl) # <--correct, but overly verbose and not clear from documentation
target_link_libraries(myApp HDF5::HDF5) # <-- link fails due to missing HL information
Notice that
find_package(HDF5 COMPONENTS C Fortran)
target_link_libraries(myApp HDF5::HDF5) # <-- equivalent to target_link_libraries(myApp hdf5::hdf5 hdf5::hdf5_fortran). convenient!
behaves as "expected", that is "All detected HDF5_LIBRARIES
".
My preference is HDF5::HDF5
should encapsulate hdf5::hdf5_hl
if it is requested, but if there is sufficient reason not to do so, then the documentation should be amended to clarify that the hdf5::hdf5_hl*
targets should be given explicitly even when the components are asked for.