FindHDF5: check that compiler wrapper is functional before using flags
A common use case where the current FindHDF5.cmake gets led astray is Miniconda / Anaconda Python being used in a CMake project. The conda hdf5 compiler wrapper is first on PATH, but the conda compiler may not be installed.
This commit:
- checks that the compiler wrapper can compile a minimal HDF5 program before using what would be "wrong" info for a broken/missing compiler
- adds typical paths seen on Linux and MSYS2
In short, for Ubuntu and MSYS2 at least, FindHDF5 before this MR relied almost entirely on the compiler wrapper. In the systems I see, there are too many broken HDF5 compiler wrappers and so this MR strengthens the FindHDF5 algorithm.
Typical HDF5 1.10 library paths
- MacOS Homebrew: lib/ | include/
- Ubuntu 18.04: <system_libdir>/hdf5/serial | <system_incdir>/hdf5/serial/
- MSYS2: <system_libdir> | <system_incdir>/{static,shared}/
- Windows native: <install_dir>/lib | <install_dir>/include/{shared,static}/
Also, Windows native does not have compiler wrappers.
Note
- this PR is unrelated to !4343 (merged)
- this PR fixes some of the issues in #20205 (closed), but more mostly orthogonal work may be needed for HDF5 1.12 (now in beta)
Issue: #20205 (closed)
Topic-rename: FindHDF5-verify-wrappers