Mercurial > minori
annotate m4/m4_ax_have_qt.m4 @ 281:3ede7be4f449
anime_season: forgot these
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Mon, 06 May 2024 17:44:16 -0400 |
| parents | f01b6e9c8fa2 |
| children |
| rev | line source |
|---|---|
| 258 | 1 # =========================================================================== |
| 2 # https://www.gnu.org/software/autoconf-archive/ax_have_qt.html | |
| 3 # =========================================================================== | |
| 4 # | |
| 5 # SYNOPSIS | |
| 6 # | |
| 7 # AX_HAVE_QT | |
| 8 # | |
| 9 # DESCRIPTION | |
| 10 # | |
| 11 # Searches $PATH and queries qmake for Qt include files, libraries and Qt | |
| 12 # binary utilities. The macro only supports Qt5 or later. | |
| 13 # | |
| 14 # The following shell variable is set to either "yes" or "no": | |
| 15 # | |
| 16 # have_qt | |
| 17 # | |
| 18 # Additionally, the following variables are exported: | |
| 19 # | |
| 20 # QT_CXXFLAGS | |
| 21 # QT_LIBS | |
| 22 # QT_MOC | |
| 23 # QT_UIC | |
| 24 # QT_RCC | |
| 25 # QT_LRELEASE | |
| 26 # QT_LUPDATE | |
| 27 # QT_DIR | |
| 28 # QMAKE | |
| 29 # | |
| 30 # which respectively contain an "-I" flag pointing to the Qt include | |
| 31 # directory, link flags necessary to link with Qt and X, the full path to | |
| 32 # the meta object compiler and the user interface compiler both, and | |
| 33 # finally the variable QTDIR as Qt likes to see it defined. | |
| 34 # | |
| 35 # Example lines for Makefile.in: | |
| 36 # | |
| 37 # CXXFLAGS = @QT_CXXFLAGS@ | |
| 38 # MOC = @QT_MOC@ | |
| 39 # | |
| 40 # After the variables have been set, a trial compile and link is performed | |
| 41 # to check the correct functioning of the meta object compiler. This test | |
| 42 # may fail when the different detected elements stem from different | |
| 43 # releases of the Qt framework. In that case, an error message is emitted | |
| 44 # and configure stops. | |
| 45 # | |
| 46 # No common variables such as $LIBS or $CFLAGS are polluted. | |
| 47 # | |
| 48 # LICENSE | |
| 49 # | |
| 50 # Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net> | |
| 51 # Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com> | |
| 52 # | |
| 53 # Copying and distribution of this file, with or without modification, are | |
| 54 # permitted in any medium without royalty provided the copyright notice | |
| 55 # and this notice are preserved. This file is offered as-is, without any | |
| 56 # warranty. | |
| 57 | |
| 58 #serial 25 | |
| 59 | |
| 60 AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT]) | |
| 61 AC_DEFUN([AX_HAVE_QT], | |
| 62 [ | |
| 63 AC_REQUIRE([AC_PROG_CXX]) | |
| 64 AC_REQUIRE([AC_PATH_X]) | |
| 65 AC_REQUIRE([AC_PATH_XTRA]) | |
| 66 # openSUSE leap 15.3 installs qmake-qt5, not qmake, for example. | |
| 67 # Store the full name (like qmake-qt5) into QMAKE | |
| 68 # and the specifier (like -qt5 or empty) into am_have_qt_qmexe_suff. | |
| 69 AC_ARG_VAR([QMAKE],"Qt make tool") | |
| 70 AC_CHECK_TOOLS([QMAKE],[qmake qmake-qt6 qmake-qt5],[false]) | |
| 71 | |
| 72 AC_MSG_CHECKING(for Qt) | |
| 73 am_have_qt_qmexe_suff=`echo $QMAKE | sed 's,^.*qmake,,'` | |
| 74 # If we have Qt5 or later in the path, we're golden | |
| 75 ver=`$QMAKE --version | grep -o "Qt version ."` | |
| 76 | |
| 77 if test "$ver" ">" "Qt version 4"; then | |
| 78 have_qt=yes | |
| 79 # This pro file dumps qmake's variables, but it only works on Qt 5 or later | |
|
271
f01b6e9c8fa2
dep/animone: make OS X code build
Paper <paper@paper.us.eu.org>
parents:
267
diff
changeset
|
80 am_have_qt_dir=$(mktemp -d || mktemp -d -t tmp) |
| 258 | 81 am_have_qt_pro="$am_have_qt_dir/test.pro" |
| 82 am_have_qt_stash="$am_have_qt_dir/.qmake.stash" | |
| 83 am_have_qt_makefile="$am_have_qt_dir/Makefile" | |
| 264 | 84 am_have_qt_makefile_vars="$am_have_qt_dir/Makefile.vars" |
| 258 | 85 # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt |
| 86 cat > $am_have_qt_pro << EOF | |
| 87 win32 { | |
| 88 CONFIG -= debug_and_release | |
| 89 CONFIG += release | |
| 90 } | |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
91 QMAKE_PROJECT_DEPTH = 0 |
| 258 | 92 qtHaveModule(core): QT += core |
| 93 qtHaveModule(gui): QT += gui | |
| 94 qtHaveModule(widgets): QT += widgets | |
| 264 | 95 EOF |
| 96 cat > "$am_have_qt_makefile_vars" << EOF | |
| 97 include $am_have_qt_makefile | |
| 98 | |
| 99 # todo: use printf here | |
| 100 CXXFLAGS: | |
| 101 @echo \$(CXXFLAGS) \$(INCPATH) | |
| 102 | |
| 103 LIBS: | |
| 104 @echo \$(LIBS) | |
| 258 | 105 EOF |
| 106 $QMAKE $am_have_qt_pro -o $am_have_qt_makefile | |
| 264 | 107 QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile_vars CXXFLAGS` |
| 108 QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile_vars LIBS` | |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
109 rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile $am_have_qt_makefile_vars |
| 258 | 110 rmdir $am_have_qt_dir |
| 111 | |
| 112 # Look for specific tools in $PATH | |
| 113 QT_MOC=`which moc$am_have_qt_qmexe_suff` | |
| 114 QT_UIC=`which uic$am_have_qt_qmexe_suff` | |
| 115 QT_RCC=`which rcc$am_have_qt_qmexe_suff` | |
| 116 QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff` | |
| 117 QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff` | |
| 118 | |
| 119 # Get Qt version from qmake | |
| 120 QT_DIR=`$QMAKE --version | grep -o -E /.+` | |
| 121 | |
| 122 # All variables are defined, report the result | |
| 123 AC_MSG_RESULT([$have_qt: | |
| 124 QT_CXXFLAGS=$QT_CXXFLAGS | |
| 125 QT_DIR=$QT_DIR | |
| 126 QT_LIBS=$QT_LIBS | |
| 127 QT_UIC=$QT_UIC | |
| 128 QT_MOC=$QT_MOC | |
| 129 QT_RCC=$QT_RCC | |
| 130 QT_LRELEASE=$QT_LRELEASE | |
| 131 QT_LUPDATE=$QT_LUPDATE]) | |
| 132 else | |
| 133 # Qt was not found | |
| 134 have_qt=no | |
| 135 QT_CXXFLAGS= | |
| 136 QT_DIR= | |
| 137 QT_LIBS= | |
| 138 QT_UIC= | |
| 139 QT_MOC= | |
| 140 QT_RCC= | |
| 141 QT_LRELEASE= | |
| 142 QT_LUPDATE= | |
| 143 AC_MSG_RESULT($have_qt) | |
| 144 fi | |
| 145 AC_SUBST(QT_CXXFLAGS) | |
| 146 AC_SUBST(QT_DIR) | |
| 147 AC_SUBST(QT_LIBS) | |
| 148 AC_SUBST(QT_UIC) | |
| 149 AC_SUBST(QT_MOC) | |
| 150 AC_SUBST(QT_RCC) | |
| 151 AC_SUBST(QT_LRELEASE) | |
| 152 AC_SUBST(QT_LUPDATE) | |
| 153 AC_SUBST(QMAKE) | |
| 154 | |
| 155 #### Being paranoid: | |
| 156 if test x"$have_qt" = xyes; then | |
| 157 AC_MSG_CHECKING(correct functioning of Qt installation) | |
| 158 AC_CACHE_VAL(ax_cv_qt_test_result, | |
| 159 [ | |
| 160 cat > ax_qt_test.h << EOF | |
| 161 #include <qobject.h> | |
| 162 class Test : public QObject | |
| 163 { | |
| 164 Q_OBJECT | |
| 165 public: | |
| 166 Test() {} | |
| 167 ~Test() {} | |
| 168 public slots: | |
| 169 void receive() {} | |
| 170 signals: | |
| 171 void send(); | |
| 172 }; | |
| 173 EOF | |
| 174 | |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
175 cat > ax_qt_main.cc << EOF |
| 258 | 176 #include "ax_qt_test.h" |
| 177 #include <qapplication.h> | |
| 178 int main( int argc, char **argv ) | |
| 179 { | |
| 180 QApplication app( argc, argv ); | |
| 181 Test t; | |
| 182 QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) ); | |
| 183 } | |
| 184 EOF | |
| 185 | |
| 186 ax_cv_qt_test_result="failure" | |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
187 ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.cc >/dev/null 2>/dev/null" |
| 258 | 188 AC_TRY_EVAL(ax_try_1) |
| 189 if test x"$ac_status" != x0; then | |
| 190 echo "$ax_err_1" >&AS_MESSAGE_LOG_FD | |
| 191 echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD | |
| 192 cat ax_qt_test.h >&AS_MESSAGE_LOG_FD | |
| 193 else | |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
194 ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.cc >/dev/null 2>/dev/null" |
| 258 | 195 AC_TRY_EVAL(ax_try_2) |
| 196 if test x"$ac_status" != x0; then | |
| 197 echo "$ax_err_2" >&AS_MESSAGE_LOG_FD | |
| 198 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD | |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
199 cat moc_ax_qt_test.cc >&AS_MESSAGE_LOG_FD |
| 258 | 200 else |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
201 ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.cc >/dev/null 2>/dev/null" |
| 258 | 202 AC_TRY_EVAL(ax_try_3) |
| 203 if test x"$ac_status" != x0; then | |
| 204 echo "$ax_err_3" >&AS_MESSAGE_LOG_FD | |
| 205 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD | |
|
267
09c5bd74fe93
win32: make builds work again
Paper <paper@paper.us.eu.org>
parents:
264
diff
changeset
|
206 cat ax_qt_main.cc >&AS_MESSAGE_LOG_FD |
| 258 | 207 else |
| 208 ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null" | |
| 209 AC_TRY_EVAL(ax_try_4) | |
| 210 if test x"$ac_status" != x0; then | |
| 211 echo "$ax_err_4" >&AS_MESSAGE_LOG_FD | |
| 212 else | |
| 213 ax_cv_qt_test_result="success" | |
| 214 fi | |
| 215 fi | |
| 216 fi | |
| 217 fi | |
| 218 ])dnl AC_CACHE_VAL ax_cv_qt_test_result | |
| 219 AC_MSG_RESULT([$ax_cv_qt_test_result]) | |
| 220 if test x"$ax_cv_qt_test_result" = "xfailure"; then | |
| 221 AC_MSG_ERROR([Failed to find matching components of a complete | |
| 222 Qt installation. Try using more options, | |
| 223 see ./configure --help.]) | |
| 224 fi | |
| 225 | |
| 226 rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \ | |
| 227 ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main | |
| 228 fi | |
| 229 ]) |
