From: Matthias Maier Date: Tue, 1 Feb 2022 15:31:15 +0000 (-0600) Subject: CMake: call CMake's FindHDF5 instead of trying to find everything by hand X-Git-Tag: v9.4.0-rc1~537^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b20e6e8d118d8256f07b82b6fafd84516777f32e;p=dealii.git CMake: call CMake's FindHDF5 instead of trying to find everything by hand --- diff --git a/cmake/modules/FindHDF5.cmake b/cmake/modules/FindHDF5.cmake index 6bd900a3ec..ec0bd63dee 100644 --- a/cmake/modules/FindHDF5.cmake +++ b/cmake/modules/FindHDF5.cmake @@ -26,30 +26,19 @@ SET(HDF5_DIR "" CACHE PATH "An optional hint to an hdf5 directory") SET_IF_EMPTY(HDF5_DIR "$ENV{HDF5_DIR}") -DEAL_II_FIND_PATH(HDF5_INCLUDE_DIR hdf5.h - HINTS ${HDF5_DIR} - PATH_SUFFIXES hdf5 hdf5/include include/hdf5 include - ) - -DEAL_II_FIND_LIBRARY(HDF5_LIBRARY NAMES hdf5 - HINTS ${HDF5_DIR} - PATH_SUFFIXES hdf5/lib lib${LIB_SUFFIX} lib64 lib - ) - -DEAL_II_FIND_LIBRARY(HDF5_HL_LIBRARY NAMES hdf5_hl - HINTS ${HDF5_DIR} - PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib - ) +# temporarily disable ${CMAKE_SOURCE_DIR}/cmake/modules for module lookup +LIST(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/) +FIND_PACKAGE(HDF5) +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/) -DEAL_II_FIND_FILE(HDF5_PUBCONF NAMES H5pubconf.h H5pubconf-64.h - HINTS ${HDF5_INCLUDE_DIR} ${HDF5_DIR} - PATH_SUFFIXES hdf5 hdf5/include include/hdf5 include - ) - -IF(EXISTS ${HDF5_PUBCONF}) +IF(HDF5_FOUND) # # Is hdf5 compiled with support for mpi? # + DEAL_II_FIND_FILE(HDF5_PUBCONF NAMES H5pubconf.h H5pubconf-64.h + HINTS ${HDF5_INCLUDE_DIRS} + PATH_SUFFIXES + ) FILE(STRINGS ${HDF5_PUBCONF} HDF5_MPI_STRING REGEX "#define.*H5_HAVE_PARALLEL 1" ) @@ -60,13 +49,20 @@ IF(EXISTS ${HDF5_PUBCONF}) ENDIF() ENDIF() + +SET(_include_dirs "${HDF5_INCLUDE_DIRS}") +SET(_libraries "${HDF5_LIBRARIES};${HDF5_HL_LIBRARIES}") + DEAL_II_PACKAGE_HANDLE(HDF5 LIBRARIES - REQUIRED HDF5_HL_LIBRARY HDF5_LIBRARY + REQUIRED _libraries OPTIONAL MPI_C_LIBRARIES INCLUDE_DIRS - REQUIRED HDF5_INCLUDE_DIR + REQUIRED _include_dirs USER_INCLUDE_DIRS - REQUIRED HDF5_INCLUDE_DIR - CLEAR HDF5_HL_LIBRARY HDF5_LIBRARY HDF5_INCLUDE_DIR HDF5_PUBCONF + REQUIRED _include_dirs + CLEAR + HDF5_C_COMPILER_EXECUTABLE HDF5_C_LIBRARY_dl HDF5_C_LIBRARY_hdf5 + HDF5_C_LIBRARY_m HDF5_C_LIBRARY_mpi HDF5_C_LIBRARY_sz HDF5_C_LIBRARY_z + HDF5_DIFF_EXECUTABLE HDF5_PUBCONF )