Salome HOME
ParaView from install dir pointed by PVHOME
[modules/geom.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       fi
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       fi
141       if test -f ${d}/include/vtk-5.2/vtkPlane.h ; then
142         AC_MSG_RESULT(trying ${d})
143         VTKHOME="${d}"
144         VTKSUFFIX="-5.2"
145         break
146       fi
147       if test -f ${d}/include/vtk/vtkPlane.h ; then
148         AC_MSG_RESULT(trying ${d})
149         VTKHOME="${d}"
150         VTKSUFFIX=""
151         break
152       fi
153     done
154   fi
155 fi
156
157 # Using regular VTK installation
158 if test "x$with_paraview" = "x" ; then
159   LOCAL_INCLUDES="-I$VTKHOME/include/vtk${VTKSUFFIX} $LOCAL_INCLUDES"
160   LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $LOCAL_LIBS"
161   TRY_LINK_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX} -L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $TRY_LINK_LIBS"
162   if test "x$VTKHOME" != "x/usr" ; then
163     LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX} $LOCAL_LIBS"
164   fi
165 else
166 # VTK from ParaView overrides other VTK versions
167   if test "${with_paraview}" = "yes" ; then
168     if test -z $PVHOME ; then
169       PVHOME="/usr"
170     fi
171   else
172     PVHOME=${with_paraview}
173   fi
174
175
176   LOCAL_INCLUDES="-I$PVHOME/include/paraview-$PVVERSION $LOCAL_INCLUDES"
177
178   LOCAL_LIBS="-L$PVHOME/lib/paraview-$PVVERSION -lvtksys -lvtkzlib -lvtkpng -lvtkjpeg -lvtktiff -lvtkexpat -lvtksqlite -lvtkmetaio -lvtkverdict -lvtkNetCDF -lvtkDICOMParser -lvtkfreetype -lvtkftgl -lvtkexoIIc $LOCAL_LIBS"
179   TRY_LINK_LIBS="-L$PVHOME/lib/paraview-$PVVERSION -lvtksys $TRY_LINK_LIBS"
180 fi
181
182 dnl vtk headers
183 CPPFLAGS_old="$CPPFLAGS"
184 CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
185
186 AC_CHECK_HEADER(vtkPlane.h,vtk_ok="yes",vtk_ok="no")
187
188 CPPFLAGS="$CPPFLAGS_old"
189
190 if test "x$vtk_ok" = "xyes"
191 then
192    VTK_INCLUDES="$LOCAL_INCLUDES"
193
194    dnl vtk libraries
195
196    AC_MSG_CHECKING(linking VTK library)
197
198    LIBS_old="$LIBS"
199    LIBS="$LIBS $TRY_LINK_LIBS"
200    #LIBS="$LIBS $LOCAL_LIBS"
201    CPPFLAGS_old="$CPPFLAGS"
202    CPPFLAGS="$CPPFLAGS $VTK_INCLUDES"
203
204    dnl VTKPY_MODULES="$VTKHOME/python"
205
206    AC_CACHE_VAL(salome_cv_lib_vtk,[
207      AC_TRY_LINK([#include "vtkPlane.h"
208                  ],
209                  [vtkPlane::New()],
210                  [salome_cv_lib_vtk=yes],
211                  [salome_cv_lib_vtk=no])
212    ])
213    vtk_ok="$salome_cv_lib_vtk"
214    LIBS="$LIBS_old"
215    CPPFLAGS="$CPPFLAGS_old"
216 fi
217
218 if  test "x$vtk_ok" = "xno"
219 then
220   AC_MSG_RESULT(no)
221   AC_MSG_WARN(unable to link with vtk library)
222 else
223   AC_MSG_RESULT(yes)
224   VTK_LIBS="$LOCAL_LIBS"
225   VTK_MT_LIBS="$LOCAL_LIBS"
226 fi
227
228 AC_MSG_RESULT(for VTK: $vtk_ok)
229
230 AC_LANG_RESTORE
231
232 # Save cache
233 AC_CACHE_SAVE
234
235 ])dnl