Salome HOME
1b1a8d1a1845e3a92347e0306cabfec012e1afdc
[modules/kernel.git] / salome_adm / unix / config_files / check_vtk.m4
1 dnl  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 dnl 
4 dnl  This library is free software; you can redistribute it and/or 
5 dnl  modify it under the terms of the GNU Lesser General Public 
6 dnl  License as published by the Free Software Foundation; either 
7 dnl  version 2.1 of the License. 
8 dnl 
9 dnl  This library is distributed in the hope that it will be useful, 
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 dnl  Lesser General Public License for more details. 
13 dnl 
14 dnl  You should have received a copy of the GNU Lesser General Public 
15 dnl  License along with this library; if not, write to the Free Software 
16 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 dnl 
18 dnl  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 dnl
20 dnl
21 dnl
22
23 AC_DEFUN([CHECK_VTK],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CXX])dnl
26 AC_REQUIRE([AC_PROG_CPP])dnl
27 AC_REQUIRE([AC_PROG_CXXCPP])dnl
28
29 AC_CHECKING(for VTK)
30
31 AC_LANG_SAVE
32 AC_LANG_CPLUSPLUS
33
34 AC_SUBST(VTK_INCLUDES)
35 AC_SUBST(VTK_LIBS)
36 AC_SUBST(VTKPY_MODULES)
37
38 VTK_INCLUDES=""
39 VTK_LIBS=""
40 VTKPY_MODULES=""
41
42 vtk_ok=no
43
44 AC_PATH_X
45
46 if test "x$OpenGL_ok" != "xyes"
47 then
48    AC_MSG_WARN(vtk needs OpenGL correct configuration, check configure output)
49 fi
50
51
52 LOCAL_INCLUDES="$OGL_INCLUDES"
53 LOCAL_LIBS="-lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid $OGL_LIBS -L$x_libraries -lX11 -lXt"
54 TRY_LINK_LIBS="-lvtkCommon $OGL_LIBS -L$x_libraries -lX11 -lXt"
55
56 if test -z $VTKHOME
57 then 
58    AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled)
59 else
60    LOCAL_INCLUDES="-I$VTKHOME/include/vtk $LOCAL_INCLUDES"
61    LOCAL_LIBS="-L$VTKHOME/lib/vtk $LOCAL_LIBS"
62    TRY_LINK_LIBS="-L$VTKHOME/lib/vtk $TRY_LINK_LIBS"
63 fi
64
65 dnl vtk headers
66 CPPFLAGS_old="$CPPFLAGS"
67 CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES -Wno-deprecated"
68
69 AC_CHECK_HEADER(vtkPlane.h,vtk_ok="yes",vtk_ok="no")
70
71  CPPFLAGS="$CPPFLAGS_old"
72
73  if  test "x$vtk_ok" = "xyes"
74  then
75    VTK_INCLUDES="$LOCAL_INCLUDES"
76
77  dnl vtk libraries
78
79    AC_MSG_CHECKING(linking VTK library)
80
81   LIBS_old="$LIBS"
82 #  LIBS="$LIBS $TRY_LINK_LIBS"
83   LIBS="$LIBS $LOCAL_LIBS"
84   CPPFLAGS_old="$CPPFLAGS"
85   CPPFLAGS="$CPPFLAGS $VTK_INCLUDES -Wno-deprecated"
86
87  dnl  VTKPY_MODULES="$VTKHOME/python"
88
89    AC_CACHE_VAL(salome_cv_lib_vtk,[
90      AC_TRY_LINK(
91 #include "vtkPlane.h"
92 ,   vtkPlane *p = vtkPlane::New();,
93     eval "salome_cv_lib_vtk=yes",eval "salome_cv_lib_vtk=no")
94   ])
95   vtk_ok="$salome_cv_lib_vtk"
96   LIBS="$LIBS_old"
97   CPPFLAGS="$CPPFLAGS_old"
98
99 fi
100
101 if  test "x$vtk_ok" = "xno"
102 then
103   AC_MSG_RESULT("no")
104   AC_MSG_WARN(unable to link with vtk library)
105 else
106   AC_MSG_RESULT("yes")
107   VTK_LIBS="$LOCAL_LIBS"
108   VTK_MT_LIBS="$LOCAL_LIBS"
109 fi
110
111 AC_MSG_RESULT("for vtk: $vtk_ok")
112
113 AC_LANG_RESTORE
114
115 # Save cache
116 AC_CACHE_SAVE
117
118 ])dnl
119
120