Salome HOME
98af56e504956953f44fd7583c1f4ced3013f051
[modules/paravis.git] / src / Plugins / MEDReader / CMake / FindMED.cmake
1 # Copyright (C) 2010-2016  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # - Find MED library
21 # Find the MED includes and library
22 # This module defines
23 #  MED3HOME, a directory where MED was installed. This directory is used to help find trhe other values.
24 #  MED_INCLUDE_DIR, where to find med.h
25 #  MED_INCLUDE_DIRS, where to find med.h file, concatenated with other include dirs from HDF5 and MPI (if parallel)
26 #  MED_LIBRARIES, libraries to link against to use MED. (including HDF5 and MPI if parallel)
27 #  MED_FOUND, If false, do not try to use MED.
28 # also defined, but not for general use are
29 #  MED_LIBRARY, the med library.
30 #  MEDC_LIBRARY, the medC library
31
32 SET(MED3HOME $ENV{MED3HOME} CACHE PATH "Path to the med install dir")
33
34 IF(NOT MED3HOME)
35   FIND_PROGRAM(MDUMP mdump)
36   IF(MDUMP)
37     SET(MED3HOME ${MDUMP})
38     GET_FILENAME_COMPONENT(MED3HOME ${MED3HOME} PATH)
39     GET_FILENAME_COMPONENT(MED3HOME ${MED3HOME} PATH)
40   ENDIF(MDUMP)
41 ENDIF(NOT MED3HOME)
42
43 FIND_PATH(MED_INCLUDE_DIR med.h
44   HINTS
45   ${MED3HOME}/include
46   PATHS
47   /usr/local/include
48   /usr/include
49 )
50
51 FIND_LIBRARY(MED_LIBRARY med
52   HINTS
53   ${MED_INCLUDE_DIR}/../lib
54   ${MED3HOME}/lib
55   PATHS
56   /usr/local/lib
57   /usr/lib
58 )
59
60 get_filename_component(MED_LIBRARY_DIR ${MED_LIBRARY} PATH)
61
62 FIND_LIBRARY(MEDC_LIBRARY medC
63   HINTS
64   ${MED_LIBRARY_DIR}
65   ${MED3HOME}/lib
66   PATHS
67   /usr/local/lib
68   /usr/lib
69 )
70
71 IF(MED_INCLUDE_DIR)
72   IF(MED_LIBRARY)
73     IF(MEDC_LIBRARY)
74       SET(MED_LIBRARIES ${MED_LIBRARY} ${MEDC_LIBRARY} )
75       SET( MED_FOUND "YES" )
76     ENDIF(MEDC_LIBRARY)
77   ENDIF(MED_LIBRARY)
78 ENDIF(MED_INCLUDE_DIR)
79
80 IF(${MED_FOUND})
81   IF(WINDOWS)
82     SET(MED_LIBRARIES ${MED_LIBRARIES} ${HDF5_LIBS})
83     SET(MED_INCLUDE_DIRS ${MED_INCLUDE_DIR} ${HDF5_INCLUDE_DIR})
84   ELSE(WINDOWS)
85     FIND_PACKAGE(SalomeHDF5 REQUIRED)
86     SET(MED_LIBRARIES ${MED_LIBRARIES} ${HDF5_LIBRARIES})
87     SET(MED_INCLUDE_DIRS ${MED_INCLUDE_DIR} ${HDF5_INCLUDE_DIRS})
88     IF(${HDF5_IS_PARALLEL})
89       FIND_PACKAGE(SalomeMPI REQUIRED)
90       SET(MED_LIBRARIES ${MED_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
91       SET(MED_INCLUDE_DIRS ${MED_INCLUDE_DIRS} ${MPI_INCLUDE_PATH})
92     ENDIF(${HDF5_IS_PARALLEL})
93   ENDIF(WINDOWS)
94 ENDIF(${MED_FOUND})
95
96 SET(MED_INCLUDE_DIR ${MED_INCLUDE_DIRS})