Salome HOME
Copyright update 2021
[tools/configuration.git] / cmake / FindMEDFile.cmake
1 ############################################################################
2 #
3 # Detect MEDFile (med-fichier)
4 # --
5 # Defines the following variables
6 #   MEDFILE_INCLUDE_DIRS    - include directories
7 #   MEDFILE_LIBRARIES       - libraries to link against (C and Fortran)
8 #   MEDFILE_C_LIBRARIES     - C libraries only
9 #   MEDFILE_EXTRA_LIBRARIES - additional libraries
10 # --
11 #  The CMake (or environment) variable MEDFILE_ROOT_DIR can be set to
12 #  guide the detection and indicate a root directory to look into.
13 #
14 ############################################################################
15 # Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
16 #
17 # This library is free software; you can redistribute it and/or
18 # modify it under the terms of the GNU Lesser General Public
19 # License as published by the Free Software Foundation; either
20 # version 2.1 of the License, or (at your option) any later version.
21 #
22 # This library is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25 # Lesser General Public License for more details.
26 #
27 # You should have received a copy of the GNU Lesser General Public
28 # License along with this library; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
30 #
31 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
32 #
33
34 MESSAGE(STATUS "Check for medfile ...")
35 # --
36
37 SET(MEDFILE_ROOT_DIR $ENV{MEDFILE_ROOT_DIR} CACHE PATH "Path to the MEDFile.")
38 IF(MEDFILE_ROOT_DIR)
39   LIST(APPEND CMAKE_PREFIX_PATH "${MEDFILE_ROOT_DIR}")
40 ENDIF(MEDFILE_ROOT_DIR)
41 # --
42
43 # Detect headers directory
44 FIND_PATH(MEDFILE_INCLUDE_DIRS med.h)
45 # --
46
47 # Detect libraries
48 SET(MEDFILE_LIBRARIES)
49 SET(MEDFILE_C_LIBRARIES)
50 SET(MEDFILE_EXTRA_LIBRARIES)
51
52 FIND_LIBRARY(MEDFILE_LIBRARY_medC NAMES medC)
53 IF(MEDFILE_LIBRARY_medC)
54   LIST(APPEND MEDFILE_C_LIBRARIES "${MEDFILE_LIBRARY_medC}")
55   LIST(APPEND MEDFILE_LIBRARIES "${MEDFILE_LIBRARY_medC}")
56 ENDIF()
57 FIND_LIBRARY(MEDFILE_LIBRARY_medfwrap NAMES medfwrap)
58 IF(MEDFILE_LIBRARY_medfwrap)
59   LIST(APPEND MEDFILE_C_LIBRARIES "${MEDFILE_LIBRARY_medfwrap}")
60   LIST(APPEND MEDFILE_LIBRARIES "${MEDFILE_LIBRARY_medfwrap}")
61 ENDIF()
62 FIND_LIBRARY(MEDFILE_LIBRARY_med NAMES med)
63 IF(MEDFILE_LIBRARY_med)
64   LIST(APPEND MEDFILE_LIBRARIES "${MEDFILE_LIBRARY_med}")
65 ENDIF()
66 FIND_LIBRARY(MEDFILE_LIBRARY_medimport NAMES medimport)
67 IF(MEDFILE_LIBRARY_medimport)
68   LIST(APPEND MEDFILE_EXTRA_LIBRARIES "${MEDFILE_LIBRARY_medimport}")
69 ENDIF()
70
71 INCLUDE(FindPackageHandleStandardArgs)
72 FIND_PACKAGE_HANDLE_STANDARD_ARGS(MEDFile REQUIRED_VARS MEDFILE_INCLUDE_DIRS MEDFILE_LIBRARIES)