FindHDF5 with HDF5_PREFER_PARALLEL find the serial version of the library even if the parallel one is installed
Giving the following CMakeLists.txt fragment with CMake 3.14.0
# ...
set(HDF5_PREFER_PARALLEL TRUE)
find_package(HDF5 REQUIRED COMPONENTS C)
# ...
A PATH variable
PATH=/home/user/.local/anaconda3/bin:/home/user/.local/bin:/home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
And the following paths for h5pcc and h5cc
whereis h5pcc
h5pcc: /usr/bin/h5pcc.openmpi /usr/bin/h5pcc
whereis h5cc
h5cc: /usr/bin/h5cc /home/user/.local/anaconda3/bin/h5cc
Still the FindHDF5.cmake module finds the serial version. This problem is caused by the 'NAMES_PER_DIR' flag in find_program:
https://gitlab.kitware.com/cmake/cmake/blob/v3.14.1/Modules/FindHDF5.cmake#L594-602
Consider removing to disable the flag NAMES_PER_DIR when HDF5_PREFER_PARALLEL is set to TRUE. This would make it possible to find a parallel HDF5 version even if h5cc is present in a PATH directory that comes before the one containing h5pcc.