1 dnl Copyright (C) 2007-2021 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, or (at your option) any later version.
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%[/]\+$%%')
58 if test -z $QTDIR ; then
59 dnl Trying to search Qt5
60 QTDIR=$(echo $QT5_ROOT_DIR | sed 's%[/]\+$%%')
67 if test -z $with_qt ; then
70 if test "x$with_qt" = "xyes" ; then
71 dnl in case user wrote --with-qt=yes
74 if test "x$with_qt" = "xauto" ; then
75 dnl in case user wrote --with-qt=auto
78 if test "x$with_qt" = "xno" ; then
79 dnl in case user wrote --with-qt=no
81 AC_MSG_WARN(Value no, specified for option --with-qt, is not supported)
84 if test "x$with_qt" != "x" ; then
85 dnl Using "--with-qt" prefix path
87 elif test "$QTDIR" = "/usr/lib/qt3" ; then
88 dnl Using QTDIR environment variable
89 AC_MSG_RESULT(current QTDIR is $QTDIR)
91 if test -d /usr/lib/qt4 ; then
92 AC_MSG_RESULT(it is strange for a qt4 installation !)
93 AC_MSG_RESULT(/usr/lib/qt4 is present)
94 AC_MSG_RESULT(replacing QTDIR by /usr/lib/qt4)
97 elif test -z $QTDIR ; then
98 AC_MSG_WARN(undefined QTDIR variable which specify where Qt product was installed, trying to guess using pkg-config)
100 AS_IF([test "x$PKG_CONFIG" != "x"],
102 QT_REQUIRED_VERSION=4.0.0
103 if $PKG_CONFIG --exists "QtCore >= $QT_REQUIRED_VERSION"
105 QT_USING_PKGCONFIG=yes
106 QT_VERSION=`$PKG_CONFIG --modversion QtCore --atleast-version=$QT_REQUIRED_VERSION`
107 QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
109 MOC=`$PKG_CONFIG --variable=moc_location "QtCore >= $QT_REQUIRED_VERSION"`
110 UIC=`$PKG_CONFIG --variable=uic_location "QtCore >= $QT_REQUIRED_VERSION"`
111 QRCC=`$PKG_CONFIG --variable=rcc_location "QtCore >= $QT_REQUIRED_VERSION"`
112 LRELEASE=`$PKG_CONFIG --variable=lrelease_location "QtCore >= $QT_REQUIRED_VERSION"`
114 QTCORE_CPPFLAGS=`$PKG_CONFIG --cflags "QtCore >= $QT_REQUIRED_VERSION"`
115 QTGUI_CPPFLAGS=`$PKG_CONFIG --cflags "QtGui >= $QT_REQUIRED_VERSION"`
116 QTOPENGL_CPPFLAGS=`$PKG_CONFIG --cflags "QtOpenGL >= $QT_REQUIRED_VERSION"`
117 QTXML_CPPFLAGS=`$PKG_CONFIG --cflags "QtXml >= $QT_REQUIRED_VERSION"`
118 QTASSISTANT_CPPFLAGS=`$PKG_CONFIG --cflags "QtAssistant >= $QT_REQUIRED_VERSION"`
119 QTNETWORK_CPPFLAGS=`$PKG_CONFIG --cflags "QtNetwork >= $QT_REQUIRED_VERSION"`
120 QTWEBKIT_CPPFLAGS=`$PKG_CONFIG --cflags "QtWebKit >= $QT_REQUIRED_VERSION"`
122 QTCORE_LDFLAGS=`$PKG_CONFIG --libs "QtCore >= $QT_REQUIRED_VERSION"`
123 QTGUI_LDFLAGS=`$PKG_CONFIG --libs "QtGui >= $QT_REQUIRED_VERSION"`
124 QTOPENGL_LDFLAGS=`$PKG_CONFIG --libs "QtOpenGL >= $QT_REQUIRED_VERSION"`
125 QTXML_LDFLAGS=`$PKG_CONFIG --libs "QtXml >= $QT_REQUIRED_VERSION"`
126 QTASSISTANT_LDFLAGS=`$PKG_CONFIG --libs "QtAssistant >= $QT_REQUIRED_VERSION"`
127 QTNETWORK_LDFLAGS=`$PKG_CONFIG --libs "QtNetwork >= $QT_REQUIRED_VERSION"`
128 QTWEBKIT_LDFLAGS=`$PKG_CONFIG --libs "QtWebKit >= $QT_REQUIRED_VERSION"`
130 AC_MSG_WARN(Qt not found)
134 AC_MSG_WARN([pkg-config not found])
138 if test -z $QTDIR ; then
139 AC_MSG_WARN(undefined QTDIR variable which specify where Qt product was installed)
140 for d in /usr/local/lib/qt4 /usr/lib/qt4 /usr ; do
141 if test -f ${d}/lib/libQtCore.so ; then
142 AC_MSG_RESULT(trying ${d})
145 elif test -f ${d}/lib64/libQtCore.so ; then
146 AC_MSG_RESULT(trying ${d})
149 elif test -f ${d}/libQtCore.so ; then
150 AC_MSG_RESULT(trying ${d})
157 # check QTDIR environment variable
159 if test "x$QTDIR" = "x" -a "x$QT_USING_PKGCONFIG" != "xyes"
161 AC_MSG_RESULT(Please define correct path in "--with-qt" option or use correct $QTDIR variable)
168 if test "x$qt_ok" = "xyes"
170 AC_MSG_CHECKING(whether Qt version >= 4.0)
171 if test "x$QT_USING_PKGCONFIG" != "xyes"
175 AC_CHECK_FILE(${QTDIR}/include/qt4/QtCore/qglobal.h,QTINC="/qt4",QTINC="")
176 if test "x$QTINC" = "x"
178 AC_CHECK_FILE(${QTDIR}/include${QTINC}/QtCore/qglobal.h,qt_inc_ok=yes,qt_inc_ok=no)
183 if test "x$qt_inc_ok" = "xyes"
185 QT_VERSION=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/QtCore/qglobal.h | sed -e 's%^#define QT_VERSION_STR[[:space:]]*\"\([[:digit:]\.]*\)\"%\1%g'`
190 if test "x$qt_inc_ok" = "xyes" -o "x$QT_USING_PKGCONFIG" = "xyes"
192 QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
193 QT_VERSION_MAJ=`echo $QT_VERSION | awk -F. '{v=$[1];print v}'`
194 if test $QT_VERSION_ID -ge 40000
201 AC_MSG_CHECKING(Qt version)
202 AC_MSG_RESULT($QT_VERSION)
209 # check moc presence (meta-object compiler)
213 if test "x$qt_ok" = "xyes"
215 if test "x$QT_USING_PKGCONFIG" != "xyes"
217 if test -f ${QTDIR}/bin/moc
221 AC_PATH_PROG(MOC, moc)
225 if test "x$MOC" = "x"
228 AC_MSG_RESULT(moc (Qt meta-object compiler) is not in the PATH variable)
231 AC_MSG_RESULT(moc (Qt meta-object compiler) is found)
234 if test "x$qt_ok" = "xyes"
236 dnl check moc version
237 AC_MSG_CHECKING( equality Qt and moc tool version)
239 if test "x$QT_VERSION_MAJ" = "x5"
241 MOC_VERSION=`$MOC -v 2>&1 | awk 'BEGIN{FS=" "};{print $(NF)}'`
243 MOC_VERSION=`$MOC -v 2>&1 | awk 'BEGIN{FS="[[ ()]]"};{print $(NF-1)}'`
245 if test "x$QT_VERSION" = "x$MOC_VERSION"
250 AC_MSG_RESULT(moc tool and Qt product are incompatible $MOC_VERSION)
251 AC_MSG_CHECKING(for moc-qt$QT_VERSION_MAJ compatible version)
252 if test -f ${QTDIR}/bin/moc-qt$QT_VERSION_MAJ
254 MOC=${QTDIR}/bin/moc-qt$QT_VERSION_MAJ
256 qt_add=$QT_VERSION_MAJ
265 AC_MSG_CHECKING(moc tool and Qt product done)
269 # check uic presence (user interface compiler)
271 if test "x$qt_ok" = "xyes"
273 if test "x$QT_USING_PKGCONFIG" != "xyes"
275 if test "x$qt_add" = "xno"
278 if test -f ${QTDIR}/bin/uic
282 AC_PATH_PROG(UIC, uic)
286 AC_MSG_CHECKING(uic-qt$qt_add)
287 if test -f ${QTDIR}/bin/uic-qt$qt_add
289 UIC=${QTDIR}/bin/uic-qt$qt_add
291 AC_PATH_PROG(UIC, uic)
297 if test "x$UIC" = "x"
300 AC_MSG_RESULT(uic (Qt user interface compiler) is not in the PATH variable)
303 AC_MSG_RESULT(uic (Qt user interface compiler) is found)
306 if test "x$qt_ok" = "xyes"
308 dnl check uic version
309 AC_MSG_CHECKING(cheching equality Qt and uic tool version)
310 UIC_VERSION=`$UIC -version 2>&1 | awk '{print $NF}'`
311 if test "x$QT_VERSION" = "x$UIC_VERSION"
316 AC_MSG_RESULT(uic tool and Qt product are incompatible)
323 # check rcc presence (resources compiler)
325 if test "x$qt_ok" = "xyes"
327 if test "x$QT_USING_PKGONFIG" != "xyes"
329 if test "x$qt_add" = "xno"
331 if test -f ${QTDIR}/bin/rcc
333 QRCC=${QTDIR}/bin/rcc
335 AC_PATH_PROG(QRCC, rcc)
338 if test -f ${QTDIR}/bin/rcc-qt$qt_add
340 QRCC=${QTDIR}/bin/rcc-qt$qt_add
342 AC_PATH_PROG(QRCC, rcc)
347 if test "x$QRCC" = "x"
350 AC_MSG_RESULT(rcc (Qt resources compiler) is not in the PATH variable)
353 AC_MSG_RESULT(rcc (Qt resources compiler) is found)
356 if test "x$qt_ok" = "xyes"
358 dnl check rcc version
359 AC_MSG_CHECKING(cheching equality Qt and rcc tool version)
360 QRCC_VERSION=`$QRCC -v 2>&1 | awk '{print $NF}'`
361 if test "x$QT_VERSION" = "x$QRCC_VERSION"
366 AC_MSG_RESULT(rcc tool and Qt product are incompatible)
373 # check lrelease presence (translation files compiler)
375 if test "x$qt_ok" = "xyes"
377 if test "x$QT_USING_PKGCONFIG" != "xyes"
379 if test "x$qt_add" = "xno"
381 if test -f ${QTDIR}/bin/lrelease
383 LRELEASE=${QTDIR}/bin/lrelease
385 AC_PATH_PROG(LRELEASE, lrelease)
388 if test -f ${QTDIR}/bin/lrelease-qt$qt_add
390 LRELEASE=${QTDIR}/bin/lrelease-qt$qt_add
392 AC_PATH_PROG(LRELEASE, lrelease)
397 if test "x$LRELEASE" = "x"
400 AC_MSG_RESULT(lrelease (Qt translation files compiler) is not in the PATH variable)
403 AC_MSG_RESULT(lrelease (Qt translation files compiler) is found)
406 if test "x$qt_ok" = "xyes"
408 dnl check lrelease version
409 AC_MSG_CHECKING( equality of Qt and lrelease tool version)
410 LRELEASE_VERSION=`$LRELEASE -version 2>&1 | awk '{print $NF}'`
411 if test "x$QT_VERSION" = "x$LRELEASE_VERSION"
416 AC_MSG_RESULT(lrelease tool and Qt product are incompatible)
425 # check Qt header files
427 if test "x$qt_ok" = "xyes"
429 AC_CHECKING(include Qt header files)
431 CPPFLAGS_old=$CPPFLAGS
432 if test "x$QT_USING_PKGCONFIG" != "xyes"
434 CPPFLAGS="$CPPFLAGS -I${QTDIR}/include${QTINC} -I${QTDIR}/include${QTINC}/QtCore -fPIC"
436 CPPFLAGS="$CPPFLAGS $QTCORE_CPPFLAGS"
438 AC_CHECK_HEADER(QObject,qt_ok=yes,qt_ok=no)
439 CPPFLAGS=$CPPFLAGS_old
441 if test "x$qt_ok" = "xno"
443 AC_MSG_RESULT(qt header files are not found in $QTDIR/include${QTINC}/QtCore)
444 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
446 AC_MSG_RESULT(qt header files seem to be OK)
447 if test "x$QT_USING_PKGCONFIG" != "xyes"
449 QT_BASE="-I${QTDIR}/include${QTINC}"
451 QTCORE_CPPFLAGS="${QT_BASE}/QtCore"
452 QTGUI_CPPFLAGS="${QT_BASE}/QtGui"
453 QTWIDGETS_CPPFLAGS="${QT_BASE}/QtWidgets"
454 QTOPENGL_CPPFLAGS="${QT_BASE}/QtOpenGL"
455 QTWEBKIT_CPPFLAGS="${QT_BASE}/QtWebKit"
456 QTXML_CPPFLAGS="${QT_BASE}/QtXml"
458 QTASSISTANT_CPPFLAGS="${QT_BASE}/QtAssistant"
459 QTNETWORK_CPPFLAGS="${QT_BASE}/QtNetwork"
462 QT_INCLUDES="$QT_BASE $QTCORE_CPPFLAGS $QTGUI_CPPFLAGS $QTOPENGL_CPPFLAGS $QTXML_CPPFLAGS $QTWEBKIT_CPPFLAGS"
465 if test "x$QT_VERSION_MAJ" = "x5"
467 QT_INCLUDES="$QT_INCLUDES $QTWIDGETS_CPPFLAGS"
470 QT_ASSISTANT_INCLUDES="$QTASSISTANT_CPPFLAGS $QTNETWORK_CPPFLAGS"
471 QT_MT_INCLUDES="${QT_INCLUDES}"
478 if test "x$qt_ok" = "xyes"
480 AC_MSG_CHECKING(linking against Qt library)
485 if test "x$QT_VERSION_MAJ" = "x5"
489 CXXFLAGS_old=$CXXFLAGS
490 CXXFLAGS="$CXXFLAGS $QT_INCLUDES -fPIC"
493 if test "x$QT_USING_PKGCONFIG" = "xyes"
495 LIBS="$LIBS $QTCORE_LDFLAGS"
497 if test "x$QTDIR" = "x/usr" ; then
499 elif test -d ${QTDIR}/lib; then
500 QT_LIB_DIR="-L$QTDIR/lib"
501 elif test -d ${QTDIR}/lib64; then
502 QT_LIB_DIR="-L$QTDIR/lib64"
503 elif test "x$QTDIR" = "x/usr/lib/qt4" ; then
506 AC_MSG_ERROR(Can't detect Qt library directory ) #'
509 LIBS="$LIBS $QT_LIB_DIR -lQt${QT_LIB_SUFF}Core"
512 AC_CACHE_VAL(salome_cv_lib_qt,[
514 #include <QCoreApplication>
517 QCoreApplication a(n, s);
519 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
521 qt_ok="$salome_cv_lib_qt"
523 # BEGIN: for CCRT (installation of qt have only a "lib" directory)
524 if test "x$qt_ok" = "xno"
526 QT_LIB_DIR="-L$QTDIR/lib"
527 LIBS="$LIBS_old $QT_LIB_DIR -lQt${QT_LIB_SUFF}Core"
529 AC_CACHE_VAL(salome_cv_lib_qt,[
531 #include <QCoreApplication>
534 QCoreApplication a(n, s);
536 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
538 qt_ok="$salome_cv_lib_qt"
542 if test "x$qt_ok" = "xno"
545 AC_MSG_RESULT(unable to link with qt library)
546 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
550 if test "x$QT_USING_PKGCONFIG" = "xyes"
552 QT_CORE_LIBS="$QTCORE_LDFLAGS $QTXML_LDFLAGS"
553 QT_GUI_LIBS="$QTGUI_LDFLAGS $QTOPENGL_LDFLAGS $QTWEBKIT_LDFLAGS"
554 QT_ASSISTANT_LIBS="$QTASSISTANT_LDFLAGS $QTNETWORK_LDFLAGS"
556 QT_CORE_LIBS="$QT_LIB_DIR -lQt${QT_LIB_SUFF}Core -lQt${QT_LIB_SUFF}Xml"
558 QT_GUI_LIBS="$QT_LIB_DIR -lQt${QT_LIB_SUFF}Gui -lQt${QT_LIB_SUFF}OpenGL -lQt${QT_LIB_SUFF}WebKit"
559 if test "x$QT_VERSION_MAJ" = "x5"
561 QT_GUI_LIBS="$QT_GUI_LIBS -lQt5Widgets"
564 # other libs (currently not used)
565 QT_OTHER_LIBS="$QT_LIB_DIR"
566 # other libs (can be used if necessary)
567 #QT_OTHER_LIBS="$QT_LIB_DIR -lQt3Support -lQtAssistantClient -lQtDesigner -lQtNetwork -lQtSql -lQtSvg -lQtTest -ltQtUiTools"
568 QT_ASSISTANT_LIBS="$QT_LIB_DIR -lQt${QT_LIB_SUFF}AssistantClient -lQt${QT_LIB_SUFF}Network"
571 QT_LIBS="$QT_CORE_LIBS $QT_GUI_LIBS $QT_OTHER_LIBS"
572 # this flag is obsolete with Qt 4
573 QT_MT_LIBS="$QT_LIBS"
576 CXXFLAGS=$CXXFLAGS_old
586 AC_SUBST(QT_INCLUDES)
587 AC_SUBST(QT_MT_INCLUDES)
588 AC_SUBST(QT_ASSISTANT_INCLUDES)
590 AC_SUBST(QT_CORE_LIBS)
591 AC_SUBST(QT_GUI_LIBS)
592 AC_SUBST(QT_OTHER_LIBS)
595 AC_SUBST(QT_ASSISTANT_LIBS)
597 AC_SUBST(QT_VERSION_ID)
601 AC_MSG_RESULT(for Qt: $qt_ok)