Salome HOME
b24f413fd50757621bc38a192a98648ad54e348e
[plugins/blsurfplugin.git] / adm_local / unix / config_files / check_MESHGEMS_CADSURF.m4
1 dnl Copyright (C) 2007-2022  CEA/DEN, EDF R&D
2 dnl
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License, or (at your option) any later version.
7 dnl
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl Lesser General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
20 dnl  File   : check_MESHGEMS_CADSURF.m4
21 dnl  Author : Gilles DAVID, Open CASCADE S.A.S (gilles.david@opencascade.com)
22 dnl
23 AC_DEFUN([CHECK_MESHGEMS_CADSURF],[
24
25 AC_REQUIRE([AC_PROG_CXX])dnl
26 AC_REQUIRE([AC_PROG_CXXCPP])dnl
27
28 AC_CHECKING([for MeshGems-CADSurf commercial product])
29
30 AC_LANG_SAVE
31 AC_LANG_CPLUSPLUS
32
33 MESHGEMS_CADSURF_INCLUDES=""
34 MESHGEMS_CADSURF_LIBS=""
35
36 AC_ARG_WITH([meshgems],
37             [  --with-meshgems=DIR       root directory path of MeshGems-CADSurf installation])
38
39 CADSURF_ok=no
40
41 if test "$with-meshgems" != "no" ; then
42   if test "$with-meshgems" == "yes" || test "$with-meshgems" == "auto"; then
43     MESHGEMS_CADSURF_HOME=""
44   else
45     MESHGEMS_CADSURF_HOME="$with_meshgems"
46   fi
47
48   if test "$MESHGEMS_CADSURF_HOME" == "" ; then
49     if test "x$MESHGEMS_CADSURFHOME" != "x" ; then
50       MESHGEMS_CADSURF_HOME=$MESHGEMS_CADSURFHOME
51     fi
52     if test "x$CADSURFHOME" != "x" ; then
53       MESHGEMS_CADSURF_HOME=$CADSURFHOME
54     fi
55     if test "x$MESHGEMSHOME" != "x" ; then
56       MESHGEMS_CADSURF_HOME=$MESHGEMSHOME
57     fi
58   fi
59
60   if test "x$MESHGEMS_CADSURF_HOME" != "x"; then
61
62     echo
63     echo -------------------------------------------------
64     echo You are about to choose to use somehow the
65     echo MeshGems-CADSurf commercial product to generate 2D mesh.
66     echo
67
68     LOCAL_INCLUDES="-I$MESHGEMS_CADSURF_HOME/include"
69     LOCAL_LIBS="-L$MESHGEMS_CADSURF_HOME/lib/Linux"
70     archtest="$(`which arch`)"
71     if test "x$archtest" = "x" ; then
72       archtest="`uname -m`"
73     fi
74     if test $archtest = "x86_64" ; then
75         LOCAL_LIBS="-L$MESHGEMS_CADSURF_HOME/lib/Linux_64"
76     fi
77     LOCAL_LIBS="${LOCAL_LIBS} -lmeshgems -lmg-cadsurf"
78
79     CPPFLAGS_old="$CPPFLAGS"
80     CXXFLAGS_old="$CXXFLAGS"
81     CPPFLAGS="$LOCAL_INCLUDES $CPPFLAGS"
82     CXXFLAGS="$LOCAL_INCLUDES $CXXFLAGS"
83
84     AC_MSG_CHECKING([for MeshGems-CADSurf header file])
85
86     AC_CHECK_HEADER([meshgems/meshgems.h],[CADSURF_ok=yes],[CADSURF_ok=no])
87     AC_CHECK_HEADER([meshgems/cadsurf.h],[CADSURF_ok=yes],[CADSURF_ok=no])
88
89     if test "x$CADSURF_ok" == "xyes"; then
90
91       AC_MSG_CHECKING([for MeshGems-CADSurf library])
92
93       LIBS_old="$LIBS"
94       LIBS="-L. $LOCAL_LIBS $LIBS"
95
96       AC_TRY_LINK(
97 extern "C" {
98 #include "meshgems/meshgems.h"
99 },  context_new(),
100         CADSURF_ok=yes,CADSURF_ok=no
101         )
102
103       LIBS="$LIBS_old"
104
105       AC_MSG_RESULT([$CADSURF_ok])
106     fi
107
108     CPPFLAGS="$CPPFLAGS_old"
109     CXXFLAGS="$CXXFLAGS_old"
110
111   fi
112 fi
113
114 if test "x$CADSURF_ok" == xno ; then
115   AC_MSG_RESULT([for MeshGems-CADSurf: no])
116   AC_MSG_WARN([MeshGems-CADSurf includes or libraries are not found or are not properly installed])
117   AC_MSG_WARN([Cannot build without MeshGems-CADSurf. Use --with_meshgems option to define MeshGems installation.])
118 else
119   MESHGEMS_CADSURF_INCLUDES=$LOCAL_INCLUDES
120   MESHGEMS_CADSURF_LIBS=$LOCAL_LIBS
121   AC_MSG_RESULT([for MeshGems-CADSurf: yes])
122 fi
123
124 AC_SUBST(MESHGEMS_CADSURF_INCLUDES)
125 AC_SUBST(MESHGEMS_CADSURF_LIBS)
126
127 AC_LANG_RESTORE
128
129 ])dnl