Thanks to JC of Kitware at SciPy 2014, the situation with CMake and HDF5 on windows has greatly improved.
First, there's been a new release of HDF5 (1.8.13). This release removes a buggy CMake library finder (targets) file. The improperly generated file in HDF5 1.8.12 was thehdf5-targets-release.cmake file. Go get the new release now: http://www.hdfgroup.org/HDF5/release/obtain5.html
Secondly, there is a bug in CMake's builtin script for finding HDF5. On Windows, it finds a DLL before the Lib file, and won't link properly (http://public.kitware.com/Bug/view.php?id=14111). Thanks to JC, I understand that the way forward is not to patch that file, but ratherto move towards removing CMake's builtin scripts entirely, and push the responsibility of finding these libraries out to the library authors. Several library authors have already done this (including HDF5, thankfully). The included FindSomething.cmake scripts should be treated as a legacy, fallback approach. CMake has a great option for forcing the use of the library's scripts for defining libraries and headers. When calling the find_package function, you need to specify the NO_MODULE argument, like so:
FIND_PACKAGE(HDF5 "1.8.5" REQUIRED NO_MODULE)
This bypasses much of CMake's internal FindHDF5 script, and instead goes looking for hdf5-config.cmake in several locations, ideally finding it in the place we installed the HDF5 libraries. The new version of the HDF5 libraries now properly tells CMake where to find everything, and life is peachy.
In summary, use NO_MODULE when the library you're using provides a -config.cmake file. It will likely be better (more current) than CMake's internal Findsomething.cmake file. However, be careful! If not all platforms actually provide this file, then your build will break where this file does not exist. Notably, Ubuntu does not (currently) ship the hdf5-config.cmake files with the libhdf5-dev package. So, you'll need a code section like this (based onhttps://github.com/commontk/CTK/blob/master/Utilities/CMake/FindDCMTK.cmake):
# back up any user-defined HDF5_DIR setting set(_SAVED_HDF5_DIR ${HDF5_DIR}) FIND_PACKAGE(HDF5 "1.8.5" NO_MODULE) # First look for hdf5-config.cmake in defined locations. This file is generated by HDF5 team and is likely more up to date than FindHDF5.cmake included in CMake. IF(NOT HDF5_FOUND) # didn't find hdf5-config.cmake. Need to fall back on CMake's built-in FindHDF5.cmake logic. # required says we fail if it isn't found. # Restore the value reset by the previous call to 'find_package(HDF5 "1.8.5" NO_MODULE)' set(HDF5_DIR ${_SAVED_HDF5_DIR} CACHE PATH "HDF5 install dir" FORCE) FIND_PACKAGE(HDF5 "1.8.5" REQUIRED) ENDIF()
More information:
details on find_package: http://www.cmake.org/cmake/help/v3.0/command/find_package.html?highlight=find_package
Creating your own package descriptions to make includes and libraries easy for downstream users:
http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
and
http://www.cmake.org/cmake/help/git-master/manual/cmake-packages.7.html#creating-packages
Thanks again to JC for helping me figure this stuff out - now I need to get QSTEM using it!