1 dnl Copyright (C) 2009-2016 CEA/DEN, EDF R&D
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.
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.
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
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 dnl the following variables are exported:
28 dnl qt4 is searched in the following order
29 dnl path given with --with-qt4 options
30 dnl presence of QTDIR variable
32 dnl when HAS_GUI is false (no salome gui) and nothing is said for qt4, qt4 is not checked
34 dnl ./configure --prefix=/home/prascle/partage/maquettes/install
35 dnl ./configure --prefix=/home/prascle/partage/maquettes/install --with-qt4
36 dnl ./configure --prefix=/home/prascle/partage/maquettes/install --with-qt4=/opt/qt443
37 dnl ./configure --prefix=/home/prascle/partage/maquettes/install --with-qt4-includes=/usr/include/qt4
38 dnl ./configure --prefix=/home/prascle/partage/maquettes/install --with-qt4-includes=/usr/include/qt4 --with-qt4-libraries=/usr/lib -with-qt4-tools=/usr/bin
39 dnl ./configure --prefix=/home/prascle/partage/maquettes/install --without-qt4
41 AC_DEFUN([I2_CHECK_QT4],
43 AC_REQUIRE([AC_PROG_CXX])
44 AC_REQUIRE([AC_PROG_CPP])
50 # --- check if qt4 standard install directory is defined (with subdirectories bin lib include)
53 AC_HELP_STRING([--with-qt4@<:@=DIR@:>@], [where the Qt4 package with a standard install is: default @<:@$QTDIR@:>@ or @<:@/usr@:>@]),
54 [qt4_install_path=$withval], [withval=notset])
56 # --- if qt4 standard install directory is defined but with no path: QTDIR value if defined, or /usr
57 if test x${withval} = xyes
61 qt4_install_path="/usr"
63 qt4_install_path=$QTDIR
67 # --- if qt4 standard install directory is not defined
68 # if HAS_GUI= 0: Qt4 not wanted
69 # else: QTDIR value if defined, or /usr
70 if test x${withval} = xnotset
72 if test x${HAS_GUI} = x0
75 AC_MSG_NOTICE([SALOME GUI not present, Qt4 not specified, skip detection])
79 qt4_install_path="/usr"
81 if test $QTDIR = /usr/lib/qt3 ; then
82 if test -d /usr/lib/qt4 ; then
83 AC_MSG_RESULT(it is strange for a qt4 installation !)
84 AC_MSG_RESULT(/usr/lib/qt4 is present)
85 AC_MSG_RESULT(replacing QTDIR by /usr/lib/qt4)
89 qt4_install_path=$QTDIR
94 # --- if qt4 standard install directory is not wanted: --without-qt4 or --with-qt4=no
95 if test x${withval} = xno
98 AC_MSG_NOTICE([Qt4 is not wanted, skip detection])
101 QT_DIR=${qt4_install_path}
104 # ----------------------------------------------------------------------
105 # --- only when qt4 wanted (no explicit --without-qt4 nor --with-qt4=no)
107 if test x${qt4_wanted} = xyes
110 # --- check if qt4 includes directory is defined
112 AC_ARG_WITH([qt4-includes],
113 AC_HELP_STRING([--with-qt4-includes@<:@=DIR@:>@], [where the Qt4 includes are: default @<:@$QTDIR/include@:>@ or @<:@/usr/include@:>@]),
114 [qt4_include_path=$withval], [withval=no])
115 if test x${withval} != xno
117 # --- qt4 includes directory is defined
118 if test x${qt4_include_path} = xyes
120 qt4_include_path="/usr/include"
123 if test x${qt4_install_path} != x
125 qt4_include_path="${qt4_install_path}/include"
130 # --- check if qt4 libraries directory is defined
132 AC_ARG_WITH([qt4-libraries],
133 AC_HELP_STRING([--with-qt4-libraries@<:@=DIR@:>@], [where the Qt4 libraries are: default @<:@$QTDIR/lib@:>@ or @<:@/usr/lib@:>@]),
134 [qt4_library_path=$withval], [withval=no])
135 if test x${withval} != xno
137 # --- qt4 libraries directory is defined
138 if test x${qt4_library_path} = xyes
140 qt4_library_path="/usr/lib"
143 if test x${qt4_install_path} != x
145 qt4_library_path="${qt4_install_path}/lib"
149 # --- check if qt4 tools directory is defined
151 AC_ARG_WITH([qt4-tools],
152 AC_HELP_STRING([--with-qt4-tools@<:@=DIR@:>@], [where the Qt4 executable tools are: default @<:@$QTDIR/bin@:>@ or @<:@/usr/bin@:>@]),
153 [qt4_tools_path=$withval], [withval=no])
154 if test x${withval} != xno
156 # --- qt4 tools directory is defined
157 if test x${qt4_tools_path} = xyes
159 qt4_tools_path="/usr/bin"
162 if test x${qt4_install_path} != x
164 qt4_tools_path="${qt4_install_path}/bin"
169 # test if qt4 is completely defined
171 if test x${qt4_include_path} = x
174 AC_MSG_NOTICE([No Qt4 include path defined])
176 AC_MSG_NOTICE([Qt4 include path is ${qt4_include_path}])
178 if test x${qt4_library_path} = x
181 AC_MSG_NOTICE([No Qt4 library path defined])
183 AC_MSG_NOTICE([Qt4 library path is ${qt4_library_path}])
185 if test x${qt4_tools_path} = x
188 AC_MSG_NOTICE([No Qt4 tools path defined])
190 AC_MSG_NOTICE([Qt4 tools path is ${qt4_tools_path}])
193 # saving values for compilation variables
194 saved_CPPFLAGS=$CPPFLAGS
195 saved_LDFLAGS=$LDFLAGS
198 if ! test x${qt4_defined} = xno
200 # ask for qt4 support
201 AC_MSG_NOTICE([checking whether qt4 tools and headers are present])
203 # --- we test the presence of moc,first under the form moc-qt4, then moc
204 AC_PATH_PROGS(qt4_moc_found, [moc-qt4 moc], no, ${qt4_tools_path})
205 test x${qt4_moc_found} = xno && AC_MSG_ERROR([Qt4 moc command NOT FOUND])
206 QT_MOC=$qt4_moc_found
209 # --- we test the presence of uic,first under the form uic-qt4, then uic
210 AC_PATH_PROGS(qt4_uic_found, [uic-qt4 uic], no, ${qt4_tools_path})
211 test x${qt4_uic_found} = xno && AC_MSG_ERROR([Qt4 uic command NOT FOUND])
212 QT_UIC=$qt4_uic_found
215 # --- we test the presence of rcc,first under the form rcc-qt4, then rcc
216 AC_PATH_PROGS(qt4_rcc_found, [rcc-qt4 rcc], no, ${qt4_tools_path})
217 test x${qt4_rcc_found} = xno && AC_MSG_ERROR([Qt4 rcc command NOT FOUND])
218 QT_RCC=$qt4_rcc_found
221 # --- we test the header file presence and usability
223 AC_CHECK_FILE($qt4_include_path/qt4/QtCore/qglobal.h,QTINC="/qt4",QTINC="")
224 qt4_include_path="$qt4_include_path${QTINC}"
226 qt4_cppflags="${qt4_cppflags} -I$qt4_include_path/QtCore"
227 qt4_cppflags="${qt4_cppflags} -I$qt4_include_path/QtGui"
228 qt4_cppflags="${qt4_cppflags} -I$qt4_include_path/Qt"
229 qt4_cppflags="${qt4_cppflags} -I$qt4_include_path"
230 CPPFLAGS="${CPPFLAGS} ${qt4_cppflags}"
232 AC_CHECK_HEADERS([qapplication.h],
233 [qt4_header_found=yes],
234 [qt4_header_found=no],
237 test x${qt4_header_found} = xno && AC_MSG_ERROR([Qt4 include file NOT FOUND])
238 AC_SUBST(qt4_cppflags)
240 # --- we test the library file presence and usability
241 if test x${qt4_library_path} = x/usr/lib
245 qt4_ldflags="-L$qt4_library_path"
248 AC_MSG_NOTICE([checking whether link with qt4 is working])
249 qt4_libs="-lQtCore -lQtGui"
250 LDFLAGS="${LDFLAGS} ${qt4_ldflags}"
251 LIBS="${LIBS} ${qt4_libs}"
254 AC_LINK_IFELSE([AC_LANG_PROGRAM(
255 [[ #include <QApplication>
256 #include <QPushButton> ]],
257 [[ QApplication app(0, 0);
258 QPushButton hello("Hello world!");
259 hello.resize(100, 30);
261 [qt4_lib_found=yes], [qt4_lib_found=no] )
263 test x${qt4_lib_found} = xno && AC_MSG_ERROR([Qt4 library NOT FOUND])
266 AC_SUBST(qt4_ldflags)
269 # --- after all tests are successful, we support Qt4
272 AC_MSG_NOTICE([Qt4 support is OK])
276 AC_MSG_NOTICE([No Qt4 support])
279 # restoring saved values
280 CPPFLAGS=$saved_CPPFLAGS
281 LDFLAGS=$saved_LDFLAGS
285 # --- end: only when qt4 wanted (no explicit --without-qt4 nor --with-qt4=no)
286 # ----------------------------------------------------------------------
288 # Propagate test into atlocal
291 # Propagate test into Makefiles...
292 AM_CONDITIONAL(WITH_QT4, test $WITH_QT4 = 1)
294 # ... and into source files
295 AC_DEFINE_UNQUOTED(HAS_QT4, $WITH_QT4, [Qt4 library])
300 AC_DEFUN([I2_CHECK_QSCINTILLA],
302 AC_REQUIRE([I2_CHECK_QT4])
306 # ----------------------------------------------------------------------
307 # --- check qscintilla only when qt4 OK
309 if test x${WITH_QT4} = x1
312 # --- check if qsci4 includes directory is defined
313 qsci4_include_path=""
316 AC_ARG_WITH([qsci4-includes],
317 AC_HELP_STRING([--with-qsci4-includes@<:@=DIR@:>@], [where the Qsci4 includes are: default @<:@$QTDIR/include/Qsci@:>@ or @<:@/usr/include/Qsci@:>@]),
318 [qsci4_include_path=$withval])
320 if test x${qsci4_include_path} = x ; then
321 # --- "" --- try to use QSCINTILLA_DIR/include/Qsci
322 if test "x${QSCINTILLA_DIR}" != "x" ; then
323 qsci4_include_path="${QSCINTILLA_DIR}/include"
325 qsci4_include_path=no
329 if test x${qsci4_include_path} = xno ; then
330 # --- "no" --- no native installation, try to find in Qt
331 qsci4_include_path="${QT_DIR}/include${QTINC}/Qsci"
332 qsci4_cppflags=" -I$qsci4_include_path"
333 # " -I${QT_DIR}/include${QTINC}" is included in qt4_cppflags
335 if test x${qsci4_include_path} = xyes ; then
336 # --- "yes" --- try to find in /usr/include/Qsci
337 qsci4_include_path="/usr/include${QTINC}/Qsci"
338 qsci4_cppflags=" -I$qsci4_include_path"
339 # " -I/usr/include${QTINC}" is included in qt4_cppflags or by default (if QTINC is empty)
341 # --- "other" --- try to find in given dir
342 qsci4_cppflags=" -I$qsci4_include_path/Qsci -I$qsci4_include_path"
346 AC_MSG_NOTICE($qsci4_cppflags)
348 # --- check if qsci4 libraries directory is defined
349 qsci4_library_path=""
351 AC_ARG_WITH([qsci4-libraries],
352 AC_HELP_STRING([--with-qsci4-libraries@<:@=DIR@:>@], [where the Qsci4 libraries are: default @<:@$QTDIR/lib@:>@ or @<:@/usr/lib@:>@]),
353 [qsci4_library_path=$withval])
355 if test x${qsci4_library_path} = x ; then
356 # --- "" --- try to use QSCINTILLA_DIR/lib
357 if test "x${QSCINTILLA_DIR}" != "x" ; then
358 qsci4_library_path="${QSCINTILLA_DIR}/lib"
360 qsci4_library_path=no
364 if test x${qsci4_library_path} = xno ; then
365 # --- "no" --- no native installation, try to find in Qt
366 qsci4_library_path="${QT_DIR}/lib"
368 if test x${qsci4_library_path} = xyes ; then
369 # --- "yes" --- try to find in /usr/lib
370 qsci4_library_path="/usr/lib"
374 AC_MSG_NOTICE($qsci4_library_path)
376 # saving values for compilation variables
377 saved_CPPFLAGS=$CPPFLAGS
378 saved_LDFLAGS=$LDFLAGS
381 # ask for qsci4 support
382 AC_MSG_NOTICE([checking whether qscintilla for qt4 headers are present])
384 # --- we test the header file presence and usability
385 CPPFLAGS="${CPPFLAGS} ${qsci4_cppflags} ${qt4_cppflags}"
387 AC_CHECK_HEADERS([qsciscintilla.h],
388 [qsci4_header_found=yes],
389 [qsci4_header_found=no],
392 if test x${qsci4_header_found} = xyes
394 AC_SUBST(qsci4_cppflags)
396 # --- we test the library file presence and usability
397 if test x${qsci4_library_path} = x/usr/lib/qt4/lib
399 qsci4_library_path=/usr/lib
401 if test x${qsci4_library_path} = x/usr/lib
405 qsci4_ldflags="-L$qsci4_library_path"
408 AC_MSG_NOTICE([checking whether qscintilla2 library is present])
409 qsci4_libs=-lqscintilla2
410 AC_CHECK_FILE([${qsci4_library_path}/libqscintilla2.so],
411 [qsci4_library_found=yes],
412 [qsci4_library_found=no])
413 if test x${qsci4_library_found} = xyes
415 AC_MSG_NOTICE([qscintilla for qt4 support])
416 AC_SUBST(qsci4_ldflags)
423 AC_MSG_NOTICE([no support for qscintilla for qt4])
426 # restoring saved values
427 CPPFLAGS=$saved_CPPFLAGS
428 LDFLAGS=$saved_LDFLAGS
432 # --- end: check qscintilla only when qt4 OK
433 # ----------------------------------------------------------------------
434 AC_MSG_NOTICE([qscintilla for qt4 not checked because Qt4 not wanted or not detected])
437 # Propagate test into atlocal
440 # Propagate test into Makefiles...
441 AM_CONDITIONAL(WITH_QSCI4, test $WITH_QSCI4 = 1)
443 # ... and into source files
444 AC_DEFINE_UNQUOTED(HAS_QSCI4, $WITH_QSCI4, [QsciScintilla library])