1######################################################################## 2# See associated tribits/Copyright.txt file for copyright and license! # 3######################################################################## 4 5# 6# First, set up the variables for the (backward-compatible) TriBITS way of 7# finding HDF5. These are used in case FIND_PACKAGE(HDF5 ...) is not called 8# or does not find HDF5. Also, these variables need to be non-null in order 9# to trigger the right behavior in the function 10# TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES(). 11# 12 13SET(REQUIRED_HEADERS hdf5.h) 14SET(REQUIRED_LIBS_NAMES hdf5) 15 16IF (HDF5_REQUIRE_FORTRAN) 17 SET(REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} hdf5_fortran) 18ENDIF() 19 20IF (TPL_ENABLE_MPI) 21 SET(REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} z) 22ENDIF() 23 24IF (TPL_ENABLE_Netcdf) 25 SET(REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} hdf5_hl) 26ENDIF() 27 28# 29# Second, search for HDF5 components (if allowed) using the standard 30# FIND_PACKAGE(HDF5 ...). 31# 32TRIBITS_TPL_ALLOW_PRE_FIND_PACKAGE(HDF5 HDF5_ALLOW_PREFIND) 33IF (HDF5_ALLOW_PREFIND) 34 35 MESSAGE("-- Using FIND_PACKAGE(HDF5 ...) ...") 36 37 SET(HDF5_COMPONENTS C) 38 IF (HDF5_REQUIRE_FORTRAN) 39 LIST(APPEND HDF5_COMPONENTS Fortran) 40 ENDIF() 41 42 IF (TPL_ENABLE_MPI) 43 SET(HDF5_PREFER_PARALLEL TRUE) 44 ENDIF() 45 46 FIND_PACKAGE(HDF5 COMPONENTS ${HDF5_COMPONENTS}) 47 48 # Make sure that HDF5 is parallel. 49 IF (TPL_ENABLE_MPI AND NOT HDF5_IS_PARALLEL) 50 MESSAGE(FATAL_ERROR "Trilinos is configured for MPI, HDF5 is not. 51 Did CMake find the correct libraries? 52 Try setting HDF5_INCLUDE_DIRS and/or HDF5_LIBRARY_DIRS explicitly. 53 ") 54 ENDIF() 55 56 IF (HDF5_FOUND) 57 # Tell TriBITS that we found HDF5 and there no need to look any further! 58 SET(TPL_HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} CACHE PATH 59 "HDF5 include dirs") 60 SET(TPL_HDF5_LIBRARIES ${HDF5_LIBRARIES} CACHE FILEPATH 61 "HDF5 libraries") 62 SET(TPL_HDF5_LIBRARY_DIRS ${HDF5_LIBRARY_DIRS} CACHE PATH 63 "HDF5 library dirs") 64 ENDIF() 65 66ENDIF() 67 68# 69# Third, call TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES() 70# 71TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES( HDF5 72 REQUIRED_HEADERS ${REQUIRED_HEADERS} 73 REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} 74 ) 75# NOTE: If FIND_PACKAGE(HDF5 ...) was called and successfully found HDF5, then 76# TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES() will use the already-set 77# variables TPL_HDF5_INCLUDE_DIRS and TPL_HDF5_LIBRARIES and then print them 78# out (and set some other standard variables as well). This is the final 79# "hook" into the TriBITS TPL system. 80