]> SALOME platform Git repositories - modules/gui.git/blob - adm_local/unix/config_files/check_vtk.m4
Salome HOME
c70c5adda2d7de6e8c4ee0e5892211cc698776a8
[modules/gui.git] / adm_local / unix / config_files / check_vtk.m4
1 dnl  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 dnl
6 dnl  This library is free software; you can redistribute it and/or
7 dnl  modify it under the terms of the GNU Lesser General Public
8 dnl  License as published by the Free Software Foundation; either
9 dnl  version 2.1 of the License.
10 dnl
11 dnl  This library is distributed in the hope that it will be useful,
12 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl  Lesser General Public License for more details.
15 dnl
16 dnl  You should have received a copy of the GNU Lesser General Public
17 dnl  License along with this library; if not, write to the Free Software
18 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 dnl
20 dnl  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 dnl
22 dnl  OPTIONS_VTK
23 dnl  ------------------------------------------------------------------------
24 dnl  Adds the --with-vtk=path and --with-vtk-version configure options
25 dnl
26 AC_DEFUN([OPTIONS_VTK], [
27   AC_ARG_WITH([vtk],
28               [AC_HELP_STRING([--with-vtk], [The prefix where VTK is installed (default "" means taking from environment variable)])],
29               [with_vtk=$withval], [with_vtk=""])
30
31   AC_ARG_WITH([vtk-version],
32               [AC_HELP_STRING([--with-vtk-version], [VTK include directory name is vtk-suffix, e.g. vtk-5.0/. What is the suffix? (Default "yes" means taking from environment variable)])],
33               [vtk_suffix=$withval], [vtk_suffix="yes"])
34
35   AC_ARG_WITH([paraview],
36               [AC_HELP_STRING([--with-paraview], [ParaView from the specified location is used instead of VTK (default "" means ParaView should not be used)])])
37 ])
38
39 dnl
40 dnl  CHECK_VTK
41 dnl  ------------------------------------------------------------------------
42 dnl
43 AC_DEFUN([CHECK_VTK], [
44 AC_REQUIRE([AC_PROG_CC])dnl
45 AC_REQUIRE([AC_PROG_CXX])dnl
46 AC_REQUIRE([AC_PROG_CPP])dnl
47 AC_REQUIRE([AC_PROG_CXXCPP])dnl
48 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
49
50 AC_REQUIRE([OPTIONS_VTK])dnl
51
52 AC_CHECKING(for VTK)
53
54 AC_LANG_SAVE
55 AC_LANG_CPLUSPLUS
56
57 AC_SUBST(VTK_INCLUDES)
58 AC_SUBST(VTK_LIBS)
59 AC_SUBST(VTKPY_MODULES)
60
61 VTK_INCLUDES=""
62 VTK_LIBS=""
63 VTKPY_MODULES=""
64
65 vtk_ok=no
66
67 if test "x$OpenGL_ok" != "xyes" ; then
68    AC_MSG_WARN(VTK needs OpenGL correct configuration, check configure output)
69 fi
70
71 AC_PATH_X
72 if test "x$x_libraries" != "x"
73 then
74    LXLIB="-L$x_libraries"
75 else
76    LXLIB=""
77 fi
78
79 if test "x$x_libraries" = "x/usr/lib"
80 then
81    LXLIB=""
82 fi
83
84 if test "x$x_libraries" = "x/usr/lib${LIB_LOCATION_SUFFIX}"
85 then
86    LXLIB=""
87 fi
88
89 LOCAL_INCLUDES="$OGL_INCLUDES"
90 LOCAL_LIBS="-lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets $LXLIB -lX11 -lXt"
91 TRY_LINK_LIBS="-lvtkCommon $LXLIB -lX11 -lXt"
92
93 dnl VTK version suffix
94 if test -z $vtk_suffix ; then
95   vtk_suffix="yes"
96 fi
97 if test "x$vtk_suffix" == "xno" ; then
98   dnl in case user wrote --with-vtk-version=no, use empty suffix
99   vtk_suffix=""
100 fi
101 if test "x$vtk_suffix" != "xyes" ; then
102   VTKSUFFIX="$vtk_suffix"
103 else
104   dnl in case user wrote --with-vtk-version=yes, get the suffix from env
105   if test -z $VTKSUFFIX ; then
106     VTKSUFFIX="-5.0"
107   fi
108 fi
109
110 dnl VTK install dir
111 if test -z $with_vtk ; then
112   with_vtk=""
113 fi
114 if test "x$with_vtk" = "xyes" ; then
115   dnl in case user wrote --with-vtk=yes
116   with_vtk=""
117 fi
118 if test "x$with_vtk" = "xno" ; then
119   dnl in case user wrote --with-vtk=no
120   with_vtk=""
121   AC_MSG_WARN(Value "no", specified for option --with-vtk, is not supported)
122 fi
123
124 if test "x$with_vtk" != "x" ; then
125   VTKHOME="$with_vtk"
126 else
127   if test -z $VTKHOME ; then
128     AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled)
129     for d in /usr/local /usr ; do
130       if test -f ${d}/include/vtk${VTKSUFFIX}/vtkPlane.h ; then
131         AC_MSG_RESULT(trying ${d})
132         VTKHOME="${d}"
133         break
134       else
135         if test -f ${d}/include/vtk-5.0/vtkPlane.h ; then
136           AC_MSG_RESULT(trying ${d})
137           VTKHOME="${d}"
138           VTKSUFFIX="-5.0"
139           break
140         else
141           if test -f ${d}/include/vtk/vtkPlane.h ; then
142             AC_MSG_RESULT(trying ${d})
143             VTKHOME="${d}"
144             VTKSUFFIX=""
145             break
146           fi
147         fi
148       fi
149     done
150   fi
151 fi
152
153 # Using regular VTK installation
154 if test "x$with_paraview" = "x" ; then
155   LOCAL_INCLUDES="-I$VTKHOME/include/vtk${VTKSUFFIX} $LOCAL_INCLUDES"
156   LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $LOCAL_LIBS"
157   TRY_LINK_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX} -L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $TRY_LINK_LIBS"
158   if test "x$VTKHOME" != "x/usr" ; then
159     LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX} $LOCAL_LIBS"
160   fi
161 else
162 # VTK from ParaView overrides other VTK versions
163   if test "${with_paraview}" = "yes" ; then
164     if test -z $PVHOME ; then
165       PVHOME="/usr"
166     fi
167   else
168     PVHOME=${with_paraview}
169   fi
170
171   if test -z $PVSRCHOME ; then
172     PVSRCHOME="$PVHOME/src"
173   fi
174
175   if test -z $PVINSTALLHOME ; then
176     PVINSTALLHOME="$PVHOME/bin"
177   fi
178
179   LOCAL_INCLUDES="-I$PVSRCHOME/VTK/Common -I$PVSRCHOME/VTK/Filtering -I$PVSRCHOME/VTK/GenericFiltering -I$PVSRCHOME/VTK/Graphics -I$PVSRCHOME/VTK/Hybrid -I$PVSRCHOME/VTK/Imaging -I$PVSRCHOME/VTK/Infovis -I$PVSRCHOME/VTK/IO -I$PVSRCHOME/VTK/Parallel -I$PVSRCHOME/VTK/Rendering -I$PVSRCHOME/VTK/Utilities -I$PVSRCHOME/VTK/Views -I$PVSRCHOME/VTK/VolumeRendering -I$PVSRCHOME/VTK/Widgets -I$PVINSTALLHOME/VTK -I$PVINSTALLHOME/VTK/Common -I$PVINSTALLHOME/VTK/Filtering -I$PVINSTALLHOME/VTK/GenericFiltering -I$PVINSTALLHOME/VTK/Graphics -I$PVINSTALLHOME/VTK/Hybrid -I$PVINSTALLHOME/VTK/Imaging -I$PVINSTALLHOME/VTK/Infovis -I$PVINSTALLHOME/VTK/IO -I$PVINSTALLHOME/VTK/Parallel -I$PVINSTALLHOME/VTK/Rendering -I$PVINSTALLHOME/VTK/Utilities -I$PVINSTALLHOME/VTK/Views -I$PVINSTALLHOME/VTK/VolumeRendering -I$PVINSTALLHOME/VTK/Widgets $LOCAL_INCLUDES"
180   LOCAL_LIBS="-L$PVINSTALLHOME/bin -lvtksys -lvtkzlib -lvtkpng -lvtkjpeg -lvtktiff -lvtkexpat -lvtksqlite -lvtkmetaio -lvtkverdict -lvtkNetCDF -lvtkDICOMParser -lvtkfreetype -lvtkftgl -lvtkexoIIc $LOCAL_LIBS"
181   TRY_LINK_LIBS="-L$PVINSTALLHOME/bin -lvtksys $TRY_LINK_LIBS"
182 fi
183
184 dnl vtk headers
185 CPPFLAGS_old="$CPPFLAGS"
186 CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
187
188 AC_CHECK_HEADER(vtkPlane.h,vtk_ok="yes",vtk_ok="no")
189
190 CPPFLAGS="$CPPFLAGS_old"
191
192 if test "x$vtk_ok" = "xyes"
193 then
194    VTK_INCLUDES="$LOCAL_INCLUDES"
195
196    dnl vtk libraries
197
198    AC_MSG_CHECKING(linking VTK library)
199
200    LIBS_old="$LIBS"
201    LIBS="$LIBS $TRY_LINK_LIBS"
202    #LIBS="$LIBS $LOCAL_LIBS"
203    CPPFLAGS_old="$CPPFLAGS"
204    CPPFLAGS="$CPPFLAGS $VTK_INCLUDES"
205
206    dnl VTKPY_MODULES="$VTKHOME/python"
207
208    AC_CACHE_VAL(salome_cv_lib_vtk,[
209      AC_TRY_LINK([#include "vtkPlane.h"
210                  ],
211                  [vtkPlane::New()],
212                  [salome_cv_lib_vtk=yes],
213                  [salome_cv_lib_vtk=no])
214    ])
215    vtk_ok="$salome_cv_lib_vtk"
216    LIBS="$LIBS_old"
217    CPPFLAGS="$CPPFLAGS_old"
218 fi
219
220 if  test "x$vtk_ok" = "xno"
221 then
222   AC_MSG_RESULT(no)
223   AC_MSG_WARN(unable to link with vtk library)
224 else
225   AC_MSG_RESULT(yes)
226   VTK_LIBS="$LOCAL_LIBS"
227   VTK_MT_LIBS="$LOCAL_LIBS"
228 fi
229
230 AC_MSG_RESULT(for VTK: $vtk_ok)
231
232 AC_LANG_RESTORE
233
234 # Save cache
235 AC_CACHE_SAVE
236
237 ])dnl