Define explicitly hdf5 path to lib and include and leave -DCMAKE_PREFIX_PATH.