Salome HOME
update CDMATH
[tools/solverlab.git] / CoreFlows / cmake_files / FindCDMATH.cmake
1 ##Copyright (C) arthurtalpaert.
2 ##All rights reserved.
3 ##
4 ##Redistribution and use in source and binary forms, with or without modification,
5 ##are permitted provided that the following conditions are met:
6 ##
7 ##* Redistributions of source code must retain the above copyright notice, this
8 ##  list of conditions and the following disclaimer.
9 ##
10 ##* Redistributions in binary form must reproduce the above copyright notice, this
11 ##  list of conditions and the following disclaimer in the documentation and/or
12 ##  other materials provided with the distribution.
13 ##
14 ##THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ##ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 ##WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 ##DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18 ##ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 ##(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 ##LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 ##ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 ##(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 ##SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25 # - Try to find CDMATH
26 # Once done this will define
27 #
28 #  CDMATH_FOUND        - system has CDMATH
29 #  CDMATH_INCLUDES     - the CDMATH include directories
30 #  CDMATH_LIBRARIES    - Link these to use CDMATH
31 #
32 #  Usage:
33 #  find_package(CDMATH)
34 #
35 # Setting these changes the behavior of the search:
36 #  CDMATH_DIR - directory in which CDMATH resides
37 #
38 # Redistribution and use is allowed according to the terms of the BSD license.
39 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
40 #
41
42 find_path (CDMATH_DIR include/CdmathException.hxx
43   HINTS ENV CDMATH_DIR
44   PATHS
45   /usr
46   $ENV{HOME}/cdmath
47   $ENV{HOME}/workspace/cdmath_install
48   DOC "CDMATH Directory")
49 message (STATUS "Found CDMATH: ${CDMATH_DIR}")
50
51 # Include directories
52 # This sets the variable ${CDMATH_INCLUDES}.
53 set(CDMATH_INCLUDES ${CDMATH_DIR}/include)
54 if (NOT (IS_DIRECTORY  ${CDMATH_INCLUDES}) )
55   message (SEND_ERROR "CDMATH_INCLUDES can not be used, ${CDMATH_INCLUDES} does not exist.")
56 endif () 
57 set(MED_INCLUDES $ENV{MEDFILE_INCLUDE_DIRS})
58 if (NOT (IS_DIRECTORY  ${MED_INCLUDES}) )
59   message (SEND_ERROR "MED_INCLUDES can not be used, ${MED_INCLUDES} does not exist.")
60 endif () 
61 set(MEDCOUPLING_INCLUDES $ENV{MEDCOUPLING_INCLUDE_DIR})
62 if (NOT (IS_DIRECTORY  ${MEDCOUPLING_INCLUDES}) )
63   message (SEND_ERROR "MEDCOUPLING_INCLUDES can not be used, ${MEDCOUPLING_INCLUDES} does not exist.")
64 endif () 
65
66 # CDMATH libraries against which to link
67 # This sets the variable ${CDMATH_LIBRARIES}.
68 set(CDMATH_LIBDIR ${CDMATH_DIR}/lib)
69 if ( NOT (IS_DIRECTORY  ${CDMATH_LIBDIR}) )
70   message (SEND_ERROR "CDMATH_LIBDIR can not be used, ${CDMATH_LIBDIR} does not exist.")
71 endif () 
72 find_library (CDMATHBASE_LIB NAMES base PATHS ${CDMATH_LIBDIR})
73 find_library (CDMATHMESH_LIB NAMES mesh PATHS ${CDMATH_LIBDIR})
74 find_library (MEDC_LIB NAMES medC PATHS $ENV{MEDFILE_LIBRARIES})
75 find_library (MEDLOADER_LIB NAMES medloader PATHS $ENV{MEDCOUPLING_LIBRARIES})
76 find_library (MEDCOUPLING_LIB NAMES medcoupling PATHS $ENV{MEDCOUPLING_LIBRARIES})
77 find_library (CDMATHLINEARSOLVER_LIB NAMES linearsolver PATHS ${CDMATH_LIBDIR})
78 set (CDMATH_LIBRARIES
79         ${MEDC_LIB} 
80         ${MEDLOADER_LIB} 
81         ${MEDCOUPLING_LIB}
82         ${CDMATHBASE_LIB} 
83         ${CDMATHMESH_LIB} 
84         ${CDMATHLINEARSOLVER_LIB}
85         )