Add make and cmake building flags and C++ macros to make HDF5 optional