Link what you use

Some tests are explicitly using HDF5, so we should explicitly link against them, too. The same is true in only place for libm. The only reason why we didn't see linking errors so far is that libnetcdf, against which all of the tests are linked, also depends on HDF5.

The diff looks bigger than it is: Most of this pull request consists of simply moving the macro definitions further down in the respective. `CMakeLists.txt` to get access to `${HDF5_*_LIBRARIES}`.