]> SALOME platform Git repositories - tools/configuration.git/blob - cmake/FindNetgen.cmake
Salome HOME
0023412: EDF 14194 - Conflict with native SWIG
[tools/configuration.git] / cmake / 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-2016  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 # Windows specific stuff:
45 # Since netgen-5.3.1 uses zlib, try to detect it
46 IF(WIN32)
47   IF(EXISTS ${NETGEN_ROOT_DIR}/cmake/FindZlib.cmake)
48     FILE(TO_CMAKE_PATH ${NETGEN_ROOT_DIR}/cmake NETGEN_CMAKE_FILES)
49     LIST(APPEND CMAKE_MODULE_PATH ${NETGEN_CMAKE_FILES})
50     SET(ZLIB_ROOT_DIR $ENV{ZLIB_ROOT_DIR})
51     MESSAGE("RNV ${ZLIB_ROOT_DIR}")
52     INCLUDE(FindZlib)
53   ENDIF()
54 ENDIF()
55
56 FIND_PATH(_netgen_base_inc_dir nglib.h)
57 SET(NETGEN_INCLUDE_DIRS ${_netgen_base_inc_dir} ${ZLIB_INCLUDE_DIRS})
58 FIND_PATH(_netgen_add_inc_dir occgeom.hpp HINTS ${_netgen_base_inc_dir} PATH_SUFFIXES share/netgen/include)
59 LIST(APPEND NETGEN_INCLUDE_DIRS ${_netgen_add_inc_dir})
60 LIST(REMOVE_DUPLICATES NETGEN_INCLUDE_DIRS)
61
62 FOREACH(_lib nglib csg gen geom2d gprim interface la mesh occ stl)
63
64   FIND_LIBRARY(NETGEN_${_lib} NAMES ${_lib})
65   IF(NETGEN_${_lib})
66     LIST(APPEND NETGEN_LIBRARIES ${NETGEN_${_lib}})
67   ENDIF()
68
69 ENDFOREACH()
70
71 INCLUDE(FindPackageHandleStandardArgs)
72 FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETGEN REQUIRED_VARS NETGEN_INCLUDE_DIRS NETGEN_LIBRARIES)
73
74 INCLUDE(CheckCXXSourceCompiles)
75
76 IF(NETGEN_FOUND)
77
78   # Detect NETGEN V5
79   SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${NETGEN_INCLUDE_DIRS}")
80   SET(CMAKE_REQUIRED_LIBRARIES "${NETGEN_LIBRARIES}")
81   CHECK_CXX_SOURCE_COMPILES("
82     #include <meshing.hpp>
83     int main()
84     {
85       netgen::Mesh* ngMesh = 0;
86       ngMesh->CalcLocalH(1.0);
87     }
88 " NETGEN_V5
89     )
90
91   IF(NOT Netgen_FIND_QUIETLY)
92     MESSAGE(STATUS "Netgen library: ${NETGEN_LIBRARIES}")
93   ENDIF()
94   SET(NETGEN_DEFINITIONS "-DOCCGEOMETRY")
95
96   IF(NETGEN_V5)
97     MESSAGE(STATUS "NETGEN V5 or later found")
98     SET(NETGEN_DEFINITIONS "${NETGEN_DEFINITIONS} -DNETGEN_V5")
99   ENDIF(NETGEN_V5)
100
101   #RNV:  currently on windows use netgen without thread support.
102   #TODO: check support of the multithreading on windows
103   IF(WIN32)
104    SET(NETGEN_DEFINITIONS "${NETGEN_DEFINITIONS} -DNO_PARALLEL_THREADS")
105   ENDIF(WIN32)
106 ENDIF()