]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: call CMake's FindHDF5 instead of trying to find everything by hand
authorMatthias Maier <tamiko@43-1.org>
Tue, 1 Feb 2022 15:31:15 +0000 (09:31 -0600)
committerMatthias Maier <tamiko@43-1.org>
Wed, 2 Feb 2022 10:28:45 +0000 (04:28 -0600)
cmake/modules/FindHDF5.cmake

index 6bd900a3ecaedcf45ce3d9f02cb486e76e034822..ec0bd63deef4d201a0c99b7bc7a8a6b9936f589e 100644 (file)
 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
   )

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.