1 # Copyright (C) 2013-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 # Author: Adrien Bruneton
22 # HDF5 detection for Salome
24 # !! Please read the generic detection procedure in SalomeMacros.cmake !!
26 # --- HDF5 specificities ----
27 # MPI root directory used for HDF5 compilation is exposed into MPI_ROOT_DIR_EXP
30 SET(HDF5_ROOT_DIR $ENV{HDF5_ROOT_DIR} CACHE PATH "Path to the HDF5.")
33 SET (HDF5_ROOT ${HDF5_ROOT_DIR})
36 SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(HDF5 HDF5_INCLUDE_DIR 1)
37 MARK_AS_ADVANCED(FORCE HDF5_INCLUDE_DIR HDF5_LIB HDF5_DIR)
39 # Stupidly enough, CONFIG mode and MODULE mode for HDF5 do not return the same thing ...!
40 SET(HDF5_INCLUDE_DIRS "${HDF5_INCLUDE_DIRS};${HDF5_INCLUDE_DIR}")
41 # Same story with libraries - if in CONFIG mode, HDF5_LIBRARIES is not defined:
42 IF(NOT DEFINED HDF5_LIBRARIES)
44 SET(HDF5_LIBRARIES hdf5)
45 ELSEIF(TARGET hdf5::hdf5-shared)
46 SET(HDF5_LIBRARIES hdf5::hdf5-shared)
51 ## 7. Specific to HDF5 only:
52 ## Expose MPI configuration to the rest of the world
54 IF(HDF5_ENABLE_PARALLEL OR HDF5_IS_PARALLEL)
55 # Set only one reference boolean variable:
56 # (unfortunately what is found in /usr/share/cmake/Modules/FindHDF5.cmake
57 # and in the native HDF5-config.cmake differ!)
58 SET(HDF5_IS_PARALLEL TRUE)
60 # HDF5 was compiled with MPI support
61 # Unfortunately HDF5 doesn't expose its MPI configuration easily ...
62 # We sniff the properties of the HDF5 target which should also be there:
63 IF(NOT DEFINED HDF5_LIBRARIES)
64 SET(HDF5_LIBRARIES "hdf5")
65 IF(NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared)
66 # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc
67 SET(_target_prefix "hdf5::")
69 SET(_suffix "-shared")
70 SET(HDF5_LIBRARIES "${_target_prefix}hdf5${_suffix}")
72 GET_PROPERTY(_lib_lst TARGET ${HDF5_LIBRARIES} PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG)
73 FOREACH(s ${_lib_lst})
74 STRING(FIND "${s}" "mpi." _res) # should cover WIN(?) and LINUX
76 GET_FILENAME_COMPONENT(_tmp "${s}" PATH) # go up to levels
77 GET_FILENAME_COMPONENT(MPI_ROOT_DIR_EXP "${_tmp}" PATH)
81 IF(NOT SalomeHDF5_FIND_QUIETLY)
82 MESSAGE(STATUS "HDF5 was compiled with MPI: ${MPI_ROOT_DIR_EXP}")
87 ADD_DEFINITIONS(-DH5_USE_16_API)
89 ADD_DEFINITIONS(-D_HDF5USEDLL_)
92 ## Ensure SALOME uses MPI if HDF5 was parallel:
93 IF(HDF5_IS_PARALLEL AND NOT SALOME_USE_MPI)
94 MESSAGE(FATAL_ERROR "HDF5 is compiled with MPI, you have to set SALOME_USE_MPI to ON")
98 SALOME_ACCUMULATE_HEADERS(HDF5_INCLUDE_DIRS)
99 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${HDF5_LIBRARIES})