2 # Sets the following variables:
3 # NETGEN_DEFINITIONS - compile flags
4 # NETGEN_INCLUDE_DIRS - path to the NETGEN include directories
5 # NETGEN_LIBRARIES - path to the NETGEN libraries to be linked against
8 #########################################################################
9 # Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
11 # This library is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU Lesser General Public
13 # License as published by the Free Software Foundation; either
14 # version 2.1 of the License, or (at your option) any later version.
16 # This library is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # Lesser General Public License for more details.
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this library; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
30 IF(NOT Netgen_FIND_QUIETLY)
31 MESSAGE(STATUS "Check for Netgen ...")
36 SET(NETGEN_ROOT_DIR $ENV{NETGEN_ROOT_DIR})
39 LIST(APPEND CMAKE_PREFIX_PATH "${NETGEN_ROOT_DIR}")
40 ENDIF(NETGEN_ROOT_DIR)
42 # Windows specific stuff:
43 # Since netgen-5.3.1 uses zlib, try to detect it
45 IF(EXISTS ${NETGEN_ROOT_DIR}/cmake/FindZlib.cmake)
46 FILE(TO_CMAKE_PATH ${NETGEN_ROOT_DIR}/cmake NETGEN_CMAKE_FILES)
47 LIST(APPEND CMAKE_MODULE_PATH ${NETGEN_CMAKE_FILES})
48 SET(ZLIB_ROOT_DIR $ENV{ZLIB_ROOT_DIR})
53 FIND_PATH(_netgen_base_inc_dir nglib.h)
54 SET(NETGEN_INCLUDE_DIRS ${_netgen_base_inc_dir} ${ZLIB_INCLUDE_DIRS})
55 FIND_PATH(_netgen_add_inc_dir1 occgeom.hpp HINTS ${_netgen_base_inc_dir} PATH_SUFFIXES share/netgen/include include)
56 IF(_netgen_add_inc_dir1)
57 LIST(APPEND NETGEN_INCLUDE_DIRS ${_netgen_add_inc_dir1})
59 FIND_PATH(_netgen_add_inc_dir2 exception.hpp HINTS ${_netgen_base_inc_dir} PATH_SUFFIXES share/netgen/include share/netgen/include/core include include/core)
60 IF(_netgen_add_inc_dir2)
61 LIST(APPEND NETGEN_INCLUDE_DIRS ${_netgen_add_inc_dir2})
64 FOREACH(_lib nglib csg gen geom2d gprim interface la mesh occ stl ngcore)
66 FIND_LIBRARY(NETGEN_${_lib} NAMES ${_lib})
68 LIST(APPEND NETGEN_LIBRARIES ${NETGEN_${_lib}})
73 INCLUDE(FindPackageHandleStandardArgs)
74 FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETGEN REQUIRED_VARS NETGEN_INCLUDE_DIRS NETGEN_LIBRARIES)
76 INCLUDE(CheckCXXSourceCompiles)
77 INCLUDE(CMakePushCheckState)
80 CMAKE_PUSH_CHECK_STATE()
83 SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${NETGEN_INCLUDE_DIRS}")
84 SET(CMAKE_REQUIRED_LIBRARIES "${NETGEN_LIBRARIES}")
85 CHECK_CXX_SOURCE_COMPILES("
86 #include <meshing.hpp>
89 netgen::Mesh* ngMesh = 0;
90 ngMesh->CalcLocalH(1.0);
95 SET(CMAKE_REQUIRED_FLAGS "-std=c++17")
96 CHECK_CXX_SOURCE_COMPILES("
97 //using namespace std;
98 #include <meshing.hpp>
101 netgen::MeshingParameters mp;
102 return !mp.meshsizefilename.empty();
107 CMAKE_POP_CHECK_STATE()
109 IF(NOT Netgen_FIND_QUIETLY)
110 MESSAGE(STATUS "Netgen library: ${NETGEN_LIBRARIES}")
112 SET(NETGEN_DEFINITIONS "-DOCCGEOMETRY")
114 #RNV: currently on windows use netgen without thread support.
115 #TODO: check support of the multithreading on windows
117 SET(NETGEN_DEFINITIONS "${NETGEN_DEFINITIONS} -DNO_PARALLEL_THREADS")