Use HDF5_FOUND to control autoconf and CMake built FindHDF5.

This commit is contained in:
Will Dicharry 2011-05-24 15:27:30 -06:00
parent 2ba826e060
commit 4e12284424
1 changed files with 34 additions and 35 deletions

View File

@ -180,8 +180,9 @@ macro( _HDF5_parse_compile_line
endmacro() endmacro()
# Try to find HDF5 using an installed hdf5-config.cmake # Try to find HDF5 using an installed hdf5-config.cmake
find_package( HDF5 QUIET NO_MODULE ) if( NOT HDF5_FOUND )
if( HDF5_INCLUDE_DIR ) find_package( HDF5 QUIET NO_MODULE )
if( HDF5_FOUND )
set( HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR} ) set( HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR} )
set( HDF5_LIBRARIES ) set( HDF5_LIBRARIES )
set( HDF5_C_TARGET hdf5 ) set( HDF5_C_TARGET hdf5 )
@ -198,12 +199,10 @@ if( HDF5_INCLUDE_DIR )
list( APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY} ) list( APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY} )
endif() endif()
endforeach() endforeach()
endif()
endif() endif()
if( HDF5_INCLUDE_DIRS AND HDF5_LIBRARIES ) if( NOT HDF5_FOUND )
# Do nothing: we already have HDF5_INCLUDE_PATH and HDF5_LIBRARIES in the
# cache, it would be a shame to override them
else()
_HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE ) _HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE )
_HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE ) _HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE )
_HDF5_invoke_compiler( Fortran HDF5_Fortran_COMPILE_LINE HDF5_Fortran_RETURN_VALUE ) _HDF5_invoke_compiler( Fortran HDF5_Fortran_COMPILE_LINE HDF5_Fortran_RETURN_VALUE )
@ -259,9 +258,7 @@ else()
${HDF5_${LANGUAGE}_LIBRARY_NAMES} ) ${HDF5_${LANGUAGE}_LIBRARY_NAMES} )
# find the HDF5 libraries # find the HDF5 libraries
message( STATUS "FindHDF5 -- search for ${LANGUAGE}" )
foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES} ) foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES} )
message( STATUS "FindHDF5 -- Searching for ${LIB}" )
if( UNIX AND HDF5_USE_STATIC_LIBRARIES ) if( UNIX AND HDF5_USE_STATIC_LIBRARIES )
# According to bug 1643 on the CMake bug tracker, this is the # According to bug 1643 on the CMake bug tracker, this is the
# preferred method for searching for a static library. # preferred method for searching for a static library.
@ -358,7 +355,8 @@ find_package_handle_standard_args( HDF5 DEFAULT_MSG
HDF5_INCLUDE_DIRS HDF5_INCLUDE_DIRS
) )
mark_as_advanced( if( HDF5_FOUND )
mark_as_advanced(
HDF5_INCLUDE_DIRS HDF5_INCLUDE_DIRS
HDF5_LIBRARIES HDF5_LIBRARIES
HDF5_DEFINTIONS HDF5_DEFINTIONS
@ -367,7 +365,8 @@ mark_as_advanced(
HDF5_CXX_COMPILER_EXECUTABLE HDF5_CXX_COMPILER_EXECUTABLE
HDF5_Fortran_COMPILER_EXECUTABLE ) HDF5_Fortran_COMPILER_EXECUTABLE )
# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of # For backwards compatibility we set HDF5_INCLUDE_DIR to the value of
# HDF5_INCLUDE_DIRS # HDF5_INCLUDE_DIRS
set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" )
endif()