FindHDF5: Add version support

Detect the HDF5 version and set HDF5_VERSION just as we
detect HDF5_IS_PARALLEL from the header already.
This commit is contained in:
Axel Huebl 2015-05-11 15:22:28 +02:00 committed by Brad King
parent 4bd122ad9c
commit 5685817874
2 changed files with 18 additions and 5 deletions

View File

@ -51,6 +51,7 @@
# bindings. # bindings.
# HDF5_LIBRARIES - Required libraries for all requested bindings # HDF5_LIBRARIES - Required libraries for all requested bindings
# HDF5_FOUND - true if HDF5 was found on the system # HDF5_FOUND - true if HDF5 was found on the system
# HDF5_VERSION - HDF5 version in format Major.Minor.Release
# HDF5_LIBRARY_DIRS - the full set of library directories # HDF5_LIBRARY_DIRS - the full set of library directories
# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support # HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support
# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler # HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler
@ -59,6 +60,7 @@
# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool # HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool
#============================================================================= #=============================================================================
# Copyright 2015 Axel Huebl, Helmholtz-Zentrum Dresden - Rossendorf
# Copyright 2009 Kitware, Inc. # Copyright 2009 Kitware, Inc.
# #
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
@ -335,6 +337,7 @@ if( NOT HDF5_FOUND )
# If the HDF5 include directory was found, open H5pubconf.h to determine if # If the HDF5 include directory was found, open H5pubconf.h to determine if
# HDF5 was compiled with parallel IO support # HDF5 was compiled with parallel IO support
set( HDF5_IS_PARALLEL FALSE ) set( HDF5_IS_PARALLEL FALSE )
set( HDF5_VERSION "" )
foreach( _dir IN LISTS HDF5_INCLUDE_DIRS ) foreach( _dir IN LISTS HDF5_INCLUDE_DIRS )
foreach(_hdr "${_dir}/H5pubconf.h" "${_dir}/H5pubconf-64.h" "${_dir}/H5pubconf-32.h") foreach(_hdr "${_dir}/H5pubconf.h" "${_dir}/H5pubconf-64.h" "${_dir}/H5pubconf-32.h")
if( EXISTS "${_hdr}" ) if( EXISTS "${_hdr}" )
@ -344,6 +347,16 @@ if( NOT HDF5_FOUND )
if( HDF5_HAVE_PARALLEL_DEFINE ) if( HDF5_HAVE_PARALLEL_DEFINE )
set( HDF5_IS_PARALLEL TRUE ) set( HDF5_IS_PARALLEL TRUE )
endif() endif()
unset(HDF5_HAVE_PARALLEL_DEFINE)
file( STRINGS "${_hdr}"
HDF5_VERSION_DEFINE
REGEX "^[ \t]*#[ \t]*define[ \t]+H5_VERSION[ \t]+" )
if( "${HDF5_VERSION_DEFINE}" MATCHES
"H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+).*\"" )
set( HDF5_VERSION "${CMAKE_MATCH_1}" )
endif()
unset(HDF5_VERSION_DEFINE)
endif() endif()
endforeach() endforeach()
endforeach() endforeach()
@ -359,8 +372,8 @@ if( NOT HDF5_FOUND )
endif() endif()
find_package_handle_standard_args( HDF5 DEFAULT_MSG find_package_handle_standard_args( HDF5
HDF5_LIBRARIES REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS
HDF5_INCLUDE_DIRS VERSION_VAR HDF5_VERSION
) )

View File

@ -86,8 +86,8 @@ foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG
check_version_string(${VTEST} ${VTEST}_VERSION_STRING) check_version_string(${VTEST} ${VTEST}_VERSION_STRING)
endforeach() endforeach()
foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2 LibArchive OPENSCENEGRAPH foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2
RUBY SWIG) HDF5 LibArchive OPENSCENEGRAPH RUBY SWIG)
check_version_string(${VTEST} ${VTEST}_VERSION) check_version_string(${VTEST} ${VTEST}_VERSION)
endforeach() endforeach()