Mercurial > minori
changeset 282:19eb6c4dca78
autotools: ax_have_qt sucks, use pkgconf instead
this is particularly useful because m4_ax_have_qt really
sucked when cross compiling because of qmake
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 08 May 2024 15:54:10 -0400 |
parents | 3ede7be4f449 |
children | 969a3e8c79c5 |
files | Makefile.am configure.ac m4/m4_ax_have_qt.m4 |
diffstat | 3 files changed, 17 insertions(+), 239 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.am Mon May 06 17:44:16 2024 -0400 +++ b/Makefile.am Wed May 08 15:54:10 2024 -0400 @@ -252,8 +252,8 @@ -I$(top_srcdir)/dep/utf8proc \ -I$(top_srcdir)/dep -minori_CPPFLAGS = $(QT_CPPFLAGS) $(LIBCURL_CPPFLAGS) $(minori_includes) -minori_CXXFLAGS = $(QT_CXXFLAGS) $(cflags_osx) $(cflags_glib) $(cflags_win) +minori_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(minori_includes) +minori_CXXFLAGS = $(QT_CFLAGS) $(cflags_osx) $(cflags_glib) $(cflags_win) minori_LDFLAGS = $(QT_LDFLAGS) $(ldflags_osx) $(ldflags_win) minori_DEPENDENCIES = dep/pugixml/libpugixml.la dep/animone/libanimone.la dep/anitomy/libanitomy.la
--- a/configure.ac Mon May 06 17:44:16 2024 -0400 +++ b/configure.ac Wed May 08 15:54:10 2024 -0400 @@ -21,15 +21,22 @@ AM_PROG_AR LT_INIT + dnl Qt? -have_qt=no -AX_HAVE_QT - -AS_IF([test "x$have_qt" = "xno"], [AC_MSG_ERROR([*** Qt not found.])]) -AC_SUBST([QT_LRELEASE]) -AC_SUBST([QT_LUPDATE]) -AC_SUBST([QT_MOC]) -AC_SUBST([QT_RCC]) +AS_IF([test "${enable_qt}" != "no"], [ + PKG_CHECK_MODULES([QT], [Qt5Core >= 5.5.0 Qt5Widgets Qt5Gui Qt5Svg], [ + QT_PATH="$(eval $PKG_CONFIG --variable=exec_prefix Qt5Core)" + QT_HOST_PATH="$(eval $PKG_CONFIG --variable=host_bins Qt5Core)" + QT_VERSION="$(eval $PKG_CONFIG --modversion Qt5Gui)" + AC_PATH_PROGS(QT_MOC, [moc-qt5 moc], moc, ["${QT_HOST_PATH}" "${QT_PATH}/bin"]) + AC_PATH_PROGS(QT_RCC, [rcc-qt5 rcc], rcc, ["${QT_HOST_PATH}" "${QT_PATH}/bin"]) + AC_PATH_PROGS(QT_UIC, [uic-qt5 uic], uic, ["${QT_HOST_PATH}" "${QT_PATH}/bin"]) + AC_PATH_PROGS(QT_LRELEASE, [lrelease-qt5 lrelease], lrelease, ["${QT_HOST_PATH}" "${QT_PATH}/bin"]) + AC_PATH_PROGS(QT_LUPDATE, [lupdate-qt5 lupdate], lupdate, ["${QT_HOST_PATH}" "${QT_PATH}/bin"]) + ], [ + AC_MSG_ERROR([${QT_PKG_ERRORS}]) + ]) +]) dnl need this for moc AC_PROG_MKDIR_P
--- a/m4/m4_ax_have_qt.m4 Mon May 06 17:44:16 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,229 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_have_qt.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_HAVE_QT -# -# DESCRIPTION -# -# Searches $PATH and queries qmake for Qt include files, libraries and Qt -# binary utilities. The macro only supports Qt5 or later. -# -# The following shell variable is set to either "yes" or "no": -# -# have_qt -# -# Additionally, the following variables are exported: -# -# QT_CXXFLAGS -# QT_LIBS -# QT_MOC -# QT_UIC -# QT_RCC -# QT_LRELEASE -# QT_LUPDATE -# QT_DIR -# QMAKE -# -# which respectively contain an "-I" flag pointing to the Qt include -# directory, link flags necessary to link with Qt and X, the full path to -# the meta object compiler and the user interface compiler both, and -# finally the variable QTDIR as Qt likes to see it defined. -# -# Example lines for Makefile.in: -# -# CXXFLAGS = @QT_CXXFLAGS@ -# MOC = @QT_MOC@ -# -# After the variables have been set, a trial compile and link is performed -# to check the correct functioning of the meta object compiler. This test -# may fail when the different detected elements stem from different -# releases of the Qt framework. In that case, an error message is emitted -# and configure stops. -# -# No common variables such as $LIBS or $CFLAGS are polluted. -# -# LICENSE -# -# Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net> -# Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com> -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 25 - -AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT]) -AC_DEFUN([AX_HAVE_QT], -[ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([AC_PATH_X]) - AC_REQUIRE([AC_PATH_XTRA]) - # openSUSE leap 15.3 installs qmake-qt5, not qmake, for example. - # Store the full name (like qmake-qt5) into QMAKE - # and the specifier (like -qt5 or empty) into am_have_qt_qmexe_suff. - AC_ARG_VAR([QMAKE],"Qt make tool") - AC_CHECK_TOOLS([QMAKE],[qmake qmake-qt6 qmake-qt5],[false]) - - AC_MSG_CHECKING(for Qt) - am_have_qt_qmexe_suff=`echo $QMAKE | sed 's,^.*qmake,,'` - # If we have Qt5 or later in the path, we're golden - ver=`$QMAKE --version | grep -o "Qt version ."` - - if test "$ver" ">" "Qt version 4"; then - have_qt=yes - # This pro file dumps qmake's variables, but it only works on Qt 5 or later - am_have_qt_dir=$(mktemp -d || mktemp -d -t tmp) - am_have_qt_pro="$am_have_qt_dir/test.pro" - am_have_qt_stash="$am_have_qt_dir/.qmake.stash" - am_have_qt_makefile="$am_have_qt_dir/Makefile" - am_have_qt_makefile_vars="$am_have_qt_dir/Makefile.vars" - # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt - cat > $am_have_qt_pro << EOF -win32 { - CONFIG -= debug_and_release - CONFIG += release -} -QMAKE_PROJECT_DEPTH = 0 -qtHaveModule(core): QT += core -qtHaveModule(gui): QT += gui -qtHaveModule(widgets): QT += widgets -EOF - cat > "$am_have_qt_makefile_vars" << EOF -include $am_have_qt_makefile - -# todo: use printf here -CXXFLAGS: - @echo \$(CXXFLAGS) \$(INCPATH) - -LIBS: - @echo \$(LIBS) -EOF - $QMAKE $am_have_qt_pro -o $am_have_qt_makefile - QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile_vars CXXFLAGS` - QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile_vars LIBS` - rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile $am_have_qt_makefile_vars - rmdir $am_have_qt_dir - - # Look for specific tools in $PATH - QT_MOC=`which moc$am_have_qt_qmexe_suff` - QT_UIC=`which uic$am_have_qt_qmexe_suff` - QT_RCC=`which rcc$am_have_qt_qmexe_suff` - QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff` - QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff` - - # Get Qt version from qmake - QT_DIR=`$QMAKE --version | grep -o -E /.+` - - # All variables are defined, report the result - AC_MSG_RESULT([$have_qt: - QT_CXXFLAGS=$QT_CXXFLAGS - QT_DIR=$QT_DIR - QT_LIBS=$QT_LIBS - QT_UIC=$QT_UIC - QT_MOC=$QT_MOC - QT_RCC=$QT_RCC - QT_LRELEASE=$QT_LRELEASE - QT_LUPDATE=$QT_LUPDATE]) - else - # Qt was not found - have_qt=no - QT_CXXFLAGS= - QT_DIR= - QT_LIBS= - QT_UIC= - QT_MOC= - QT_RCC= - QT_LRELEASE= - QT_LUPDATE= - AC_MSG_RESULT($have_qt) - fi - AC_SUBST(QT_CXXFLAGS) - AC_SUBST(QT_DIR) - AC_SUBST(QT_LIBS) - AC_SUBST(QT_UIC) - AC_SUBST(QT_MOC) - AC_SUBST(QT_RCC) - AC_SUBST(QT_LRELEASE) - AC_SUBST(QT_LUPDATE) - AC_SUBST(QMAKE) - - #### Being paranoid: - if test x"$have_qt" = xyes; then - AC_MSG_CHECKING(correct functioning of Qt installation) - AC_CACHE_VAL(ax_cv_qt_test_result, - [ - cat > ax_qt_test.h << EOF -#include <qobject.h> -class Test : public QObject -{ -Q_OBJECT -public: - Test() {} - ~Test() {} -public slots: - void receive() {} -signals: - void send(); -}; -EOF - - cat > ax_qt_main.cc << EOF -#include "ax_qt_test.h" -#include <qapplication.h> -int main( int argc, char **argv ) -{ - QApplication app( argc, argv ); - Test t; - QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) ); -} -EOF - - ax_cv_qt_test_result="failure" - ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.cc >/dev/null 2>/dev/null" - AC_TRY_EVAL(ax_try_1) - if test x"$ac_status" != x0; then - echo "$ax_err_1" >&AS_MESSAGE_LOG_FD - echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD - cat ax_qt_test.h >&AS_MESSAGE_LOG_FD - else - ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.cc >/dev/null 2>/dev/null" - AC_TRY_EVAL(ax_try_2) - if test x"$ac_status" != x0; then - echo "$ax_err_2" >&AS_MESSAGE_LOG_FD - echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD - cat moc_ax_qt_test.cc >&AS_MESSAGE_LOG_FD - else - ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.cc >/dev/null 2>/dev/null" - AC_TRY_EVAL(ax_try_3) - if test x"$ac_status" != x0; then - echo "$ax_err_3" >&AS_MESSAGE_LOG_FD - echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD - cat ax_qt_main.cc >&AS_MESSAGE_LOG_FD - else - 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" - AC_TRY_EVAL(ax_try_4) - if test x"$ac_status" != x0; then - echo "$ax_err_4" >&AS_MESSAGE_LOG_FD - else - ax_cv_qt_test_result="success" - fi - fi - fi - fi - ])dnl AC_CACHE_VAL ax_cv_qt_test_result - AC_MSG_RESULT([$ax_cv_qt_test_result]) - if test x"$ax_cv_qt_test_result" = "xfailure"; then - AC_MSG_ERROR([Failed to find matching components of a complete - Qt installation. Try using more options, - see ./configure --help.]) - fi - - rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \ - ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main - fi -])