Also fixes HDF5 mangling the default install prefix.
Fixes: #18287 (closed)
Cc: @todoooo @adam.grant.hendry @besoft