Improve cmake script, hdf5; read from memory buffer

This pull request includes changes for the improved cmake script and the PHDF5 example.