When configuring with cmake, defines such as -DHDF5_C_INCLUDE_DIR=x get ignored or overwritten when h5cc is found. h5cc is the packaged HDF5 utility which returns include, library, and compiler flag information for how the system's HDF5 library was built.
This first came up on a cluster which had HDF5 compiled without parallel support, but had h5cc and the hdf5 headers/libraries in the path. To counter this I was compiling my own HDF5 source and passing those command line include/library definitions to CGNS's cmake, but it was using system includes instead of those specified. This isn't a problem with the autotools build where --with-hdf5=my_hdf5_directory works as expected.
I believe the desired behavior should be that any command line definitions take priority. If this is the desired behavior, I'm happy to make a pull request to fix this.
Likely affects other CMake HDF5 variables.
With cmake you should be able to specify the hdf5 location through -DHDF5_ROOT or -DHDF5_DIR like the autotools.