1 dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
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
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.
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.
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
20 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 dnl ------------------------------------------------------------------------
25 dnl Adds the --with-qt=path
27 AC_DEFUN([OPTIONS_QT], [
29 [AC_HELP_STRING([--with-qt], [Possible usage:
30 "Qt_Install_Path" - prefix to path where Qt was installd;
31 "" or "yes" or "auto" - means seaching installed Qt product in the system (checking $QTDIR and then - standard system paths );
32 "no" - not use Qt product (is not supported)
33 By default "" option is used)])],
34 [with_qt=$withval], [with_qt=""])
38 AC_REQUIRE([AC_PROG_CC])dnl
39 AC_REQUIRE([AC_PROG_CXX])dnl
40 AC_REQUIRE([AC_PROG_CPP])dnl
41 AC_REQUIRE([AC_PROG_CXXCPP])dnl
42 AC_REQUIRE([CHECK_OPENGL])dnl
43 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
44 AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
46 AC_REQUIRE([OPTIONS_QT])dnl
50 if test "x$OpenGL_ok" != "xyes" ; then
51 AC_MSG_WARN(Qt needs OpenGL correct configuration, check configure output)
56 QTDIR=$(echo $QTDIR | sed 's%[/]\+$%%')
62 if test -z $with_qt ; then
65 if test "x$with_qt" = "xyes" ; then
66 dnl in case user wrote --with-qt=yes
69 if test "x$with_qt" = "xauto" ; then
70 dnl in case user wrote --with-qt=auto
73 if test "x$with_qt" = "xno" ; then
74 dnl in case user wrote --with-qt=no
76 AC_MSG_WARN(Value no, specified for option --with-qt, is not supported)
79 if test "x$with_qt" != "x" ; then
80 dnl Using "--with-qt" prefix path
82 elif test "$QTDIR" = "/usr/lib/qt3" ; then
83 dnl Using QTDIR environment variable
84 AC_MSG_RESULT(current QTDIR is $QTDIR)
86 if test -d /usr/lib/qt4 ; then
87 AC_MSG_RESULT(it is strange for a qt4 installation !)
88 AC_MSG_RESULT(/usr/lib/qt4 is present)
89 AC_MSG_RESULT(replacing QTDIR by /usr/lib/qt4)
92 elif test -z $QTDIR ; then
93 AC_MSG_WARN(undefined QTDIR variable which specify where Qt product was installed, trying to guess using pkg-config)
95 AS_IF([test "x$PKG_CONFIG" != "x"],
97 QT_REQUIRED_VERSION=4.0.0
98 if $PKG_CONFIG --exists "QtCore >= $QT_REQUIRED_VERSION"
100 QT_USING_PKGCONFIG=yes
101 QT_VERSION=`$PKG_CONFIG --modversion QtCore --atleast-version=$QT_REQUIRED_VERSION`
102 QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
104 MOC=`$PKG_CONFIG --variable=moc_location "QtCore >= $QT_REQUIRED_VERSION"`
105 UIC=`$PKG_CONFIG --variable=uic_location "QtCore >= $QT_REQUIRED_VERSION"`
106 QRCC=`$PKG_CONFIG --variable=rcc_location "QtCore >= $QT_REQUIRED_VERSION"`
107 LRELEASE=`$PKG_CONFIG --variable=lrelease_location "QtCore >= $QT_REQUIRED_VERSION"`
109 QTCORE_CPPFLAGS=`$PKG_CONFIG --cflags "QtCore >= $QT_REQUIRED_VERSION"`
110 QTGUI_CPPFLAGS=`$PKG_CONFIG --cflags "QtGui >= $QT_REQUIRED_VERSION"`
111 QTOPENGL_CPPFLAGS=`$PKG_CONFIG --cflags "QtOpenGL >= $QT_REQUIRED_VERSION"`
112 QTXML_CPPFLAGS=`$PKG_CONFIG --cflags "QtXml >= $QT_REQUIRED_VERSION"`
113 QTASSISTANT_CPPFLAGS=`$PKG_CONFIG --cflags "QtAssistant >= $QT_REQUIRED_VERSION"`
114 QTNETWORK_CPPFLAGS=`$PKG_CONFIG --cflags "QtNetwork >= $QT_REQUIRED_VERSION"`
115 QTWEBKIT_CPPFLAGS=`$PKG_CONFIG --cflags "QtWebKit >= $QT_REQUIRED_VERSION"`
117 QTCORE_LDFLAGS=`$PKG_CONFIG --libs "QtCore >= $QT_REQUIRED_VERSION"`
118 QTGUI_LDFLAGS=`$PKG_CONFIG --libs "QtGui >= $QT_REQUIRED_VERSION"`
119 QTOPENGL_LDFLAGS=`$PKG_CONFIG --libs "QtOpenGL >= $QT_REQUIRED_VERSION"`
120 QTXML_LDFLAGS=`$PKG_CONFIG --libs "QtXml >= $QT_REQUIRED_VERSION"`
121 QTASSISTANT_LDFLAGS=`$PKG_CONFIG --libs "QtAssistant >= $QT_REQUIRED_VERSION"`
122 QTNETWORK_LDFLAGS=`$PKG_CONFIG --libs "QtNetwork >= $QT_REQUIRED_VERSION"`
123 QTWEBKIT_LDFLAGS=`$PKG_CONFIG --libs "QtWebKit >= $QT_REQUIRED_VERSION"`
125 AC_MSG_WARN(Qt not found)
129 AC_MSG_WARN([pkg-config not found])
133 if test -z $QTDIR ; then
134 AC_MSG_WARN(undefined QTDIR variable which specify where Qt product was installed)
135 for d in /usr/local/lib/qt4 /usr/lib/qt4 /usr ; do
136 if test -f ${d}/lib/libQtCore.so ; then
137 AC_MSG_RESULT(trying ${d})
140 elif test -f ${d}/lib64/libQtCore.so ; then
141 AC_MSG_RESULT(trying ${d})
144 elif test -f ${d}/libQtCore.so ; then
145 AC_MSG_RESULT(trying ${d})
152 # check QTDIR environment variable
154 if test "x$QTDIR" = "x" -a "x$QT_USING_PKGCONFIG" != "xyes"
156 AC_MSG_RESULT(Please define correct path in "--with-qt" option or use correct $QTDIR variable)
163 if test "x$qt_ok" = "xyes"
165 AC_MSG_CHECKING(whether Qt version >= 4.0)
166 if test "x$QT_USING_PKGCONFIG" != "xyes"
170 AC_CHECK_FILE(${QTDIR}/include/qt4/QtCore/qglobal.h,QTINC="/qt4",QTINC="")
171 if test "x$QTINC" = "x"
173 AC_CHECK_FILE(${QTDIR}/include${QTINC}/QtCore/qglobal.h,qt_inc_ok=yes,qt_inc_ok=no)
178 if test "x$qt_inc_ok" = "xyes"
180 QT_VERSION=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/QtCore/qglobal.h | sed -e 's%^#define QT_VERSION_STR[[:space:]]*\"\([[:digit:]\.]*\)\"%\1%g'`
185 if test "x$qt_inc_ok" = "xyes" -o "x$QT_USING_PKGCONFIG" = "xyes"
187 QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
188 if test $QT_VERSION_ID -ge 40000
195 AC_MSG_CHECKING(Qt version)
196 AC_MSG_RESULT($QT_VERSION)
203 # check moc presence (meta-object compiler)
207 if test "x$qt_ok" = "xyes"
209 if test "x$QT_USING_PKGCONFIG" != "xyes"
211 if test -f ${QTDIR}/bin/moc
215 AC_PATH_PROG(MOC, moc)
219 if test "x$MOC" = "x"
222 AC_MSG_RESULT(moc (Qt meta-object compiler) is not in the PATH variable)
225 AC_MSG_RESULT(moc (Qt meta-object compiler) is found)
228 if test "x$qt_ok" = "xyes"
230 dnl check moc version
231 AC_MSG_CHECKING( equality Qt and moc tool version)
232 MOC_VERSION=`$MOC -v 2>&1 | awk 'BEGIN{FS="[[ ()]]"};{print $(NF-1)}'`
233 if test "x$QT_VERSION" = "x$MOC_VERSION"
238 AC_MSG_RESULT(moc tool and Qt product are incompatible $MOC_VERSION)
239 QT_VERSION_MAJ=`echo $QT_VERSION | awk -F. '{v=$[1];print v}'`
240 AC_MSG_CHECKING(for moc-qt$QT_VERSION_MAJ compatible version)
241 if test -f ${QTDIR}/bin/moc-qt$QT_VERSION_MAJ
243 MOC=${QTDIR}/bin/moc-qt$QT_VERSION_MAJ
245 qt_add=$QT_VERSION_MAJ
254 AC_MSG_CHECKING(moc tool and Qt product done)
258 # check uic presence (user interface compiler)
260 if test "x$qt_ok" = "xyes"
262 if test "x$QT_USING_PKGCONFIG" != "xyes"
264 if test "x$qt_add" = "xno"
267 if test -f ${QTDIR}/bin/uic
271 AC_PATH_PROG(UIC, uic)
275 AC_MSG_CHECKING(uic-qt$qt_add)
276 if test -f ${QTDIR}/bin/uic-qt$qt_add
278 UIC=${QTDIR}/bin/uic-qt$qt_add
280 AC_PATH_PROG(UIC, uic)
286 if test "x$UIC" = "x"
289 AC_MSG_RESULT(uic (Qt user interface compiler) is not in the PATH variable)
292 AC_MSG_RESULT(uic (Qt user interface compiler) is found)
295 if test "x$qt_ok" = "xyes"
297 dnl check uic version
298 AC_MSG_CHECKING(cheching equality Qt and uic tool version)
299 UIC_VERSION=`$UIC -version 2>&1 | awk '{print $NF}'`
300 if test "x$QT_VERSION" = "x$UIC_VERSION"
305 AC_MSG_RESULT(uic tool and Qt product are incompatible)
312 # check rcc presence (resources compiler)
314 if test "x$qt_ok" = "xyes"
316 if test "x$QT_USING_PKGONFIG" != "xyes"
318 if test "x$qt_add" = "xno"
320 if test -f ${QTDIR}/bin/rcc
322 QRCC=${QTDIR}/bin/rcc
324 AC_PATH_PROG(QRCC, rcc)
327 if test -f ${QTDIR}/bin/rcc-qt$qt_add
329 QRCC=${QTDIR}/bin/rcc-qt$qt_add
331 AC_PATH_PROG(QRCC, rcc)
336 if test "x$QRCC" = "x"
339 AC_MSG_RESULT(rcc (Qt resources compiler) is not in the PATH variable)
342 AC_MSG_RESULT(rcc (Qt resources compiler) is found)
345 if test "x$qt_ok" = "xyes"
347 dnl check rcc version
348 AC_MSG_CHECKING(cheching equality Qt and rcc tool version)
349 QRCC_VERSION=`$QRCC -v 2>&1 | awk '{print $NF}'`
350 if test "x$QT_VERSION" = "x$QRCC_VERSION"
355 AC_MSG_RESULT(rcc tool and Qt product are incompatible)
362 # check lrelease presence (translation files compiler)
364 if test "x$qt_ok" = "xyes"
366 if test "x$QT_USING_PKGCONFIG" != "xyes"
368 if test "x$qt_add" = "xno"
370 if test -f ${QTDIR}/bin/lrelease
372 LRELEASE=${QTDIR}/bin/lrelease
374 AC_PATH_PROG(LRELEASE, lrelease)
377 if test -f ${QTDIR}/bin/lrelease-qt$qt_add
379 LRELEASE=${QTDIR}/bin/lrelease-qt$qt_add
381 AC_PATH_PROG(LRELEASE, lrelease)
386 if test "x$LRELEASE" = "x"
389 AC_MSG_RESULT(lrelease (Qt translation files compiler) is not in the PATH variable)
392 AC_MSG_RESULT(lrelease (Qt translation files compiler) is found)
395 if test "x$qt_ok" = "xyes"
397 dnl check lrelease version
398 AC_MSG_CHECKING( equality of Qt and lrelease tool version)
399 LRELEASE_VERSION=`$LRELEASE -version 2>&1 | awk '{print $NF}'`
400 if test "x$QT_VERSION" = "x$LRELEASE_VERSION"
405 AC_MSG_RESULT(lrelease tool and Qt product are incompatible)
414 # check Qt header files
416 if test "x$qt_ok" = "xyes"
418 AC_CHECKING(include Qt header files)
420 CPPFLAGS_old=$CPPFLAGS
421 if test "x$QT_USING_PKGCONFIG" != "xyes"
423 CPPFLAGS="$CPPFLAGS -I${QTDIR}/include${QTINC} -I${QTDIR}/include${QTINC}/QtCore"
425 CPPFLAGS="$CPPFLAGS $QTCORE_CPPFLAGS"
427 AC_CHECK_HEADER(QObject,qt_ok=yes,qt_ok=no)
428 CPPFLAGS=$CPPFLAGS_old
430 if test "x$qt_ok" = "xno"
432 AC_MSG_RESULT(qt header files are not found in $QTDIR/include${QTINC}/QtCore)
433 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
435 AC_MSG_RESULT(qt header files seem to be OK)
436 if test "x$QT_USING_PKGCONFIG" != "xyes"
438 QT_BASE="-I${QTDIR}/include${QTINC}"
440 QTCORE_CPPFLAGS="${QT_BASE}/QtCore"
441 QTGUI_CPPFLAGS="${QT_BASE}/QtGui"
442 QTOPENGL_CPPFLAGS="${QT_BASE}/QtOpenGL"
443 QTWEBKIT_CPPFLAGS="${QT_BASE}/QtWebKit"
444 QTXML_CPPFLAGS="${QT_BASE}/QtXml"
446 QTASSISTANT_CPPFLAGS="${QT_BASE}/QtAssistant"
447 QTNETWORK_CPPFLAGS="${QT_BASE}/QtNetwork"
450 QT_INCLUDES="$QT_BASE $QTCORE_CPPFLAGS $QTGUI_CPPFLAGS $QTOPENGL_CPPFLAGS $QTXML_CPPFLAGS $QTWEBKIT_CPPFLAGS"
452 QT_ASSISTANT_INCLUDES="$QTASSISTANT_CPPFLAGS $QTNETWORK_CPPFLAGS"
453 QT_MT_INCLUDES="${QT_INCLUDES}"
460 if test "x$qt_ok" = "xyes"
462 AC_MSG_CHECKING(linking against Qt library)
464 CXXFLAGS_old=$CXXFLAGS
465 CXXFLAGS="$CXXFLAGS $QT_INCLUDES"
468 if test "x$QT_USING_PKGCONFIG" = "xyes"
470 LIBS="$LIBS $QTCORE_LDFLAGS"
472 if test "x$QTDIR" = "x/usr" ; then
474 elif test -d ${QTDIR}/lib; then
475 QT_LIB_DIR="-L$QTDIR/lib"
476 elif test -d ${QTDIR}/lib64; then
477 QT_LIB_DIR="-L$QTDIR/lib64"
478 elif test "x$QTDIR" = "x/usr/lib/qt4" ; then
481 AC_MSG_ERROR(Can't detect Qt library directory ) #'
484 LIBS="$LIBS $QT_LIB_DIR -lQtCore"
487 AC_CACHE_VAL(salome_cv_lib_qt,[
489 #include <QCoreApplication>
492 QCoreApplication a(n, s);
494 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
496 qt_ok="$salome_cv_lib_qt"
498 # BEGIN: for CCRT (installation of qt have only a "lib" directory)
499 if test "x$qt_ok" = "xno"
501 QT_LIB_DIR="-L$QTDIR/lib"
502 LIBS="$LIBS_old $QT_LIB_DIR -lQtCore"
504 AC_CACHE_VAL(salome_cv_lib_qt,[
506 #include <QCoreApplication>
509 QCoreApplication a(n, s);
511 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
513 qt_ok="$salome_cv_lib_qt"
517 if test "x$qt_ok" = "xno"
520 AC_MSG_RESULT(unable to link with qt library)
521 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
525 if test "x$QT_USING_PKGCONFIG" = "xyes"
527 QT_CORE_LIBS="$QTCORE_LDFLAGS $QTXML_LDFLAGS"
528 QT_GUI_LIBS="$QTGUI_LDFLAGS $QTOPENGL_LDFLAGS $QTWEBKIT_LDFLAGS"
529 QT_ASSISTANT_LIBS="$QTASSISTANT_LDFLAGS $QTNETWORK_LDFLAGS"
531 QT_CORE_LIBS="$QT_LIB_DIR -lQtCore -lQtXml"
533 QT_GUI_LIBS="$QT_LIB_DIR -lQtGui -lQtOpenGL -lQtWebKit"
534 # other libs (currently not used)
535 QT_OTHER_LIBS="$QT_LIB_DIR"
536 # other libs (can be used if necessary)
537 #QT_OTHER_LIBS="$QT_LIB_DIR -lQt3Support -lQtAssistantClient -lQtDesigner -lQtNetwork -lQtSql -lQtSvg -lQtTest -ltQtUiTools"
538 QT_ASSISTANT_LIBS="$QT_LIB_DIR -lQtAssistantClient -lQtNetwork"
541 QT_LIBS="$QT_CORE_LIBS $QT_GUI_LIBS $QT_OTHER_LIBS"
542 # this flag is obsolete with Qt 4
543 QT_MT_LIBS="$QT_LIBS"
546 CXXFLAGS=$CXXFLAGS_old
556 AC_SUBST(QT_INCLUDES)
557 AC_SUBST(QT_MT_INCLUDES)
558 AC_SUBST(QT_ASSISTANT_INCLUDES)
560 AC_SUBST(QT_CORE_LIBS)
561 AC_SUBST(QT_GUI_LIBS)
562 AC_SUBST(QT_OTHER_LIBS)
565 AC_SUBST(QT_ASSISTANT_LIBS)
567 AC_SUBST(QT_VERSION_ID)
571 AC_MSG_RESULT(for Qt: $qt_ok)