Mercurial > minori
comparison m4/m4_ax_have_qt.m4 @ 236:4d461ef7d424
HUGE UPDATE: convert build system to autotools
why? because cmake sucks :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 19 Jan 2024 00:24:02 -0500 |
parents | |
children | a7d0d543b334 |
comparison
equal
deleted
inserted
replaced
235:593108b3d555 | 236:4d461ef7d424 |
---|---|
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 | |
80 am_have_qt_dir=`mktemp -d` | |
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" | |
84 # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt | |
85 cat > $am_have_qt_pro << EOF | |
86 win32 { | |
87 CONFIG -= debug_and_release | |
88 CONFIG += release | |
89 } | |
90 qtHaveModule(axcontainer): QT += axcontainer | |
91 qtHaveModule(axserver): QT += axserver | |
92 qtHaveModule(concurrent): QT += concurrent | |
93 qtHaveModule(core): QT += core | |
94 qtHaveModule(dbus): QT += dbus | |
95 qtHaveModule(declarative): QT += declarative | |
96 qtHaveModule(designer): QT += designer | |
97 qtHaveModule(gui): QT += gui | |
98 qtHaveModule(help): QT += help | |
99 qtHaveModule(multimedia): QT += multimedia | |
100 qtHaveModule(multimediawidgets): QT += multimediawidgets | |
101 qtHaveModule(network): QT += network | |
102 qtHaveModule(opengl): QT += opengl | |
103 qtHaveModule(printsupport): QT += printsupport | |
104 qtHaveModule(qml): QT += qml | |
105 qtHaveModule(qmltest): QT += qmltest | |
106 qtHaveModule(x11extras): QT += x11extras | |
107 qtHaveModule(script): QT += script | |
108 qtHaveModule(scripttools): QT += scripttools | |
109 qtHaveModule(sensors): QT += sensors | |
110 qtHaveModule(serialport): QT += serialport | |
111 qtHaveModule(sql): QT += sql | |
112 qtHaveModule(svg): QT += svg | |
113 qtHaveModule(testlib): QT += testlib | |
114 qtHaveModule(uitools): QT += uitools | |
115 qtHaveModule(webkit): QT += webkit | |
116 qtHaveModule(webkitwidgets): QT += webkitwidgets | |
117 qtHaveModule(xml): QT += xml | |
118 qtHaveModule(xmlpatterns): QT += xmlpatterns | |
119 percent.target = % | |
120 percent.commands = @echo -n "\$(\$(@))\ " | |
121 QMAKE_EXTRA_TARGETS += percent | |
122 EOF | |
123 $QMAKE $am_have_qt_pro -o $am_have_qt_makefile | |
124 QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile CXXFLAGS INCPATH` | |
125 QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile LIBS` | |
126 rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile | |
127 rmdir $am_have_qt_dir | |
128 | |
129 # Look for specific tools in $PATH | |
130 QT_MOC=`which moc$am_have_qt_qmexe_suff` | |
131 QT_UIC=`which uic$am_have_qt_qmexe_suff` | |
132 QT_RCC=`which rcc$am_have_qt_qmexe_suff` | |
133 QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff` | |
134 QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff` | |
135 | |
136 # Get Qt version from qmake | |
137 QT_DIR=`$QMAKE --version | grep -o -E /.+` | |
138 | |
139 # All variables are defined, report the result | |
140 AC_MSG_RESULT([$have_qt: | |
141 QT_CXXFLAGS=$QT_CXXFLAGS | |
142 QT_DIR=$QT_DIR | |
143 QT_LIBS=$QT_LIBS | |
144 QT_UIC=$QT_UIC | |
145 QT_MOC=$QT_MOC | |
146 QT_RCC=$QT_RCC | |
147 QT_LRELEASE=$QT_LRELEASE | |
148 QT_LUPDATE=$QT_LUPDATE]) | |
149 else | |
150 # Qt was not found | |
151 have_qt=no | |
152 QT_CXXFLAGS= | |
153 QT_DIR= | |
154 QT_LIBS= | |
155 QT_UIC= | |
156 QT_MOC= | |
157 QT_RCC= | |
158 QT_LRELEASE= | |
159 QT_LUPDATE= | |
160 AC_MSG_RESULT($have_qt) | |
161 fi | |
162 AC_SUBST(QT_CXXFLAGS) | |
163 AC_SUBST(QT_DIR) | |
164 AC_SUBST(QT_LIBS) | |
165 AC_SUBST(QT_UIC) | |
166 AC_SUBST(QT_MOC) | |
167 AC_SUBST(QT_RCC) | |
168 AC_SUBST(QT_LRELEASE) | |
169 AC_SUBST(QT_LUPDATE) | |
170 AC_SUBST(QMAKE) | |
171 | |
172 #### Being paranoid: | |
173 if test x"$have_qt" = xyes; then | |
174 AC_MSG_CHECKING(correct functioning of Qt installation) | |
175 AC_CACHE_VAL(ax_cv_qt_test_result, | |
176 [ | |
177 cat > ax_qt_test.h << EOF | |
178 #include <qobject.h> | |
179 class Test : public QObject | |
180 { | |
181 Q_OBJECT | |
182 public: | |
183 Test() {} | |
184 ~Test() {} | |
185 public slots: | |
186 void receive() {} | |
187 signals: | |
188 void send(); | |
189 }; | |
190 EOF | |
191 | |
192 cat > ax_qt_main.$ac_ext << EOF | |
193 #include "ax_qt_test.h" | |
194 #include <qapplication.h> | |
195 int main( int argc, char **argv ) | |
196 { | |
197 QApplication app( argc, argv ); | |
198 Test t; | |
199 QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) ); | |
200 } | |
201 EOF | |
202 | |
203 ax_cv_qt_test_result="failure" | |
204 ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" | |
205 AC_TRY_EVAL(ax_try_1) | |
206 if test x"$ac_status" != x0; then | |
207 echo "$ax_err_1" >&AS_MESSAGE_LOG_FD | |
208 echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD | |
209 cat ax_qt_test.h >&AS_MESSAGE_LOG_FD | |
210 else | |
211 ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" | |
212 AC_TRY_EVAL(ax_try_2) | |
213 if test x"$ac_status" != x0; then | |
214 echo "$ax_err_2" >&AS_MESSAGE_LOG_FD | |
215 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD | |
216 cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD | |
217 else | |
218 ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null" | |
219 AC_TRY_EVAL(ax_try_3) | |
220 if test x"$ac_status" != x0; then | |
221 echo "$ax_err_3" >&AS_MESSAGE_LOG_FD | |
222 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD | |
223 cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD | |
224 else | |
225 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" | |
226 AC_TRY_EVAL(ax_try_4) | |
227 if test x"$ac_status" != x0; then | |
228 echo "$ax_err_4" >&AS_MESSAGE_LOG_FD | |
229 else | |
230 ax_cv_qt_test_result="success" | |
231 fi | |
232 fi | |
233 fi | |
234 fi | |
235 ])dnl AC_CACHE_VAL ax_cv_qt_test_result | |
236 AC_MSG_RESULT([$ax_cv_qt_test_result]) | |
237 if test x"$ax_cv_qt_test_result" = "xfailure"; then | |
238 AC_MSG_ERROR([Failed to find matching components of a complete | |
239 Qt installation. Try using more options, | |
240 see ./configure --help.]) | |
241 fi | |
242 | |
243 rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \ | |
244 ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main | |
245 fi | |
246 ]) |