FindHDF5: Prefer h5hl* compilers for HDF5_FIND_HL

Prefer `h5hlcc`, `h5hlc++`, and `h5hlfc` compilers when HDF5's HL libraries
are requested. These include the `-lhdf_hl` in the command line, whereas
the non-hl compilers (like `h5cc`) do not. Using the latter, therefore,
leads to cmake complaining about not finding the `HDF5_HL` libraries even
though they are present in the same location as the `hdf5` library itself.

Fixes: #23261
This commit is contained in:
Atri Bhattacharya 2025-03-10 20:55:36 +05:30 committed by Brad King
parent 7c55e2a698
commit a869b79c59

View File

@ -218,6 +218,13 @@ else()
set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc)
endif()
# Prefer h5hl<LANG> compilers if HDF5_FIND_HL is enabled
if(HDF5_FIND_HL)
list(PREPEND HDF5_C_COMPILER_NAMES h5hlcc)
list(PREPEND HDF5_CXX_COMPILER_NAMES h5hlc++)
list(PREPEND HDF5_Fortran_COMPILER_NAMES h5hlfc)
endif()
# Test first if the current compilers automatically wrap HDF5
function(_HDF5_test_regular_compiler_C success version is_parallel)
if(NOT ${success} OR