Salome HOME
Copyrights update 2015.
[plugins/netgenplugin.git] / adm_local / cmake_files / FindNetgen.cmake
1 # - Find NETGEN
2 # Sets the following variables:
3 #   NETGEN_INCLUDE_DIRS - path to the NETGEN include directories
4 #   NETGEN_LIBRARIES    - path to the NETGEN libraries to be linked against
5 #
6
7 #########################################################################
8 # Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
9 #
10 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
11 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
12 #
13 # This library is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU Lesser General Public
15 # License as published by the Free Software Foundation; either
16 # version 2.1 of the License, or (at your option) any later version.
17 #
18 # This library is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 # Lesser General Public License for more details.
22 #
23 # You should have received a copy of the GNU Lesser General Public
24 # License along with this library; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
26 #
27 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
28 #
29
30 # ------
31
32 IF(NOT Netgen_FIND_QUIETLY)
33   MESSAGE(STATUS "Check for Netgen ...")
34 ENDIF()
35
36 # ------
37
38 SET(NETGEN_ROOT_DIR $ENV{NETGEN_ROOT_DIR})
39
40 IF(NETGEN_ROOT_DIR)
41  LIST(APPEND CMAKE_PREFIX_PATH "${NETGEN_ROOT_DIR}")
42 ENDIF(NETGEN_ROOT_DIR)
43
44 FIND_PATH(_netgen_base_inc_dir nglib.h)
45 SET(NETGEN_INCLUDE_DIRS ${_netgen_base_inc_dir})
46 FIND_PATH(_netgen_add_inc_dir occgeom.hpp HINTS ${_netgen_base_inc_dir} PATH_SUFFIXES share/netgen/include)
47 LIST(APPEND NETGEN_INCLUDE_DIRS ${_netgen_add_inc_dir})
48 LIST(REMOVE_DUPLICATES NETGEN_INCLUDE_DIRS)
49
50 FIND_LIBRARY(NETGEN_nglib NAMES nglib)
51 IF(WIN32)
52   FIND_LIBRARY(NETGEN_csg NAMES csg)
53   FIND_LIBRARY(NETGEN_gen NAMES gen)
54   FIND_LIBRARY(NETGEN_geom2d NAMES geom2d)
55   FIND_LIBRARY(NETGEN_gprim NAMES gprim)
56   FIND_LIBRARY(NETGEN_interface NAMES interface)
57   FIND_LIBRARY(NETGEN_la NAMES la)
58   FIND_LIBRARY(NETGEN_mesh NAMES mesh)
59   FIND_LIBRARY(NETGEN_occ NAMES occ)
60   FIND_LIBRARY(NETGEN_stl NAMES stl)
61 ENDIF(WIN32)
62
63 SET(NETGEN_LIBRARIES ${NETGEN_nglib})
64
65 IF(WIN32)
66   SET(NETGEN_LIBRARIES ${NETGEN_LIBRARIES}
67       ${NETGEN_csg}
68       ${NETGEN_gen}
69       ${NETGEN_geom2d}
70       ${NETGEN_gprim}
71       ${NETGEN_interface}
72       ${NETGEN_la}
73       ${NETGEN_mesh}
74       ${NETGEN_occ}
75       ${NETGEN_stl}
76    )
77 ENDIF(WIN32)
78
79 INCLUDE(FindPackageHandleStandardArgs)
80 FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETGEN REQUIRED_VARS NETGEN_INCLUDE_DIRS NETGEN_LIBRARIES)
81
82 INCLUDE(CheckCXXSourceCompiles)
83
84 IF(NETGEN_FOUND)
85
86   SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${NETGEN_INCLUDE_DIRS}")
87   SET(CMAKE_REQUIRED_LIBRARIES "${NETGEN_LIBRARIES}")
88   CHECK_CXX_SOURCE_COMPILES("
89     #include <meshing.hpp>
90     
91     int main()
92     {
93       netgen::Mesh* ngMesh;
94       ngMesh->CalcLocalH(1.0);
95     }
96 " NETGEN_V5
97     )
98
99   IF(NOT Netgen_FIND_QUIETLY)
100     MESSAGE(STATUS "Netgen library: ${NETGEN_LIBRARIES}")
101   ENDIF()
102   SET(NETGEN_DEFINITIONS "-DOCCGEOMETRY")
103
104   IF(NETGEN_V5)
105     MESSAGE(STATUS "NETGEN V5 or later found")
106     SET(NETGEN_DEFINITIONS "${NETGEN_DEFINITIONS} -DNETGEN_V5")
107   ENDIF(NETGEN_V5)
108
109   #RNV:  currently on windows use netgen without thread support.
110   #TODO: check support of the multithreading on windows
111   IF(WIN32)
112    SET(NETGEN_DEFINITIONS "${NETGEN_DEFINITIONS} -DNO_PARALLEL_THREADS")
113   ENDIF(WIN32)
114 ENDIF()