Fixed problems with cmake files

Problems included:
 - Was using LIBHARU_* instead of LIBHPDF_*
 - Was using a add_definitions() hack for -DLIBHPDF_HAVE_NOPNGLIB,
   rather than using define flags in the generated config files.
 - Generated config files were not correctly importing the cmake variables.
 - Added extra HAVE_MEMORY_H and friend detection routines,
   to match what automake does.