Improve Qt6 detection

There is still no clear pattern of how distributions will install Qt6.
The old scheme of adding a -qtN suffix is not followed by OpenSuse,
and qmake and the ancillary programs are installed with 6 as a suffix.
This commit is contained in:
Enrico Forestieri 2021-03-21 11:28:11 +01:00
parent 4421b721e4
commit 4b20ae9d59

View File

@ -72,12 +72,13 @@ AC_DEFUN([QT_CHECK_COMPILE],
AC_DEFUN([QT_FIND_TOOL], AC_DEFUN([QT_FIND_TOOL],
[ [
$1= $1=
qt_ext=qt4 qt_major=4
if test "x$USE_QT6" != "xno" ; then if test "x$USE_QT6" != "xno" ; then
qt_ext=qt6 qt_major=6
elif test "x$USE_QT5" != "xno" ; then elif test "x$USE_QT5" != "xno" ; then
qt_ext=qt5 qt_major=5
fi fi
qt_ext="qt$qt_major"
if test -n "$qt_cv_bin" ; then if test -n "$qt_cv_bin" ; then
AC_PATH_PROGS($1, [$2], [], $qt_cv_bin) AC_PATH_PROGS($1, [$2], [], $qt_cv_bin)
@ -91,7 +92,7 @@ AC_DEFUN([QT_FIND_TOOL],
fi fi
fi fi
if test -z "$$1"; then if test -z "$$1"; then
AC_CHECK_PROGS($1, [$2-$qt_ext $2],[],$PATH) AC_CHECK_PROGS($1, [$2-$qt_ext $2$qt_major $2],[],$PATH)
fi fi
if test -z "$$1"; then if test -z "$$1"; then
AC_MSG_ERROR([cannot find $2 binary.]) AC_MSG_ERROR([cannot find $2 binary.])
@ -401,7 +402,16 @@ AC_DEFUN([QT6_QMAKE_CONFIG],
AC_MSG_CHECKING([for Qt6]) AC_MSG_CHECKING([for Qt6])
dnl Use first qmake in PATH dnl Use first qmake in PATH
ver=`qmake -v | grep -o "Qt version ."` ver=`qmake -v | grep -o "Qt version ."`
qmake6=""
if test "$ver" = "Qt version 6"; then if test "$ver" = "Qt version 6"; then
qmake6="qmake"
else
ver=`qmake6 -v | grep -o "Qt version ."`
if test "$ver" = "Qt version 6"; then
qmake6="qmake6"
fi
fi
if test -n "$qmake6" ; then
dnl Use a .pro file for getting qmake's variables dnl Use a .pro file for getting qmake's variables
lyx_test_qt_dir=`mktemp -d` lyx_test_qt_dir=`mktemp -d`
lyx_test_qt_pro="$lyx_test_qt_dir/test.pro" lyx_test_qt_pro="$lyx_test_qt_dir/test.pro"
@ -413,12 +423,12 @@ percent.target = %
percent.commands = @echo -n "\$(\$(@))\ " percent.commands = @echo -n "\$(\$(@))\ "
QMAKE_EXTRA_TARGETS += percent QMAKE_EXTRA_TARGETS += percent
EOF1 EOF1
qmake $lyx_test_qt_pro -o $lyx_test_qt_mak 1>/dev/null 2>&1 $qmake6 $lyx_test_qt_pro -o $lyx_test_qt_mak 1>/dev/null 2>&1
QT_CORE_INCLUDES=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak INCPATH | sed 's/-I\. //g'` QT_CORE_INCLUDES=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak INCPATH | sed 's/-I\. //g'`
qt_corelibs=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak LIBS` qt_corelibs=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak LIBS`
QT_CORE_LDFLAGS=`echo $qt_corelibs | tr ' ' '\n' | grep -e "^-L" | tr '\n' ' '` QT_CORE_LDFLAGS=`echo $qt_corelibs | tr ' ' '\n' | grep -e "^-L" | tr '\n' ' '`
if test -z "$QT_CORE_LDFLAGS"; then if test -z "$QT_CORE_LDFLAGS"; then
QT_CORE_LDFLAGS="-L`qmake -query QT_INSTALL_LIBS`" QT_CORE_LDFLAGS="-L`$qmake6 -query QT_INSTALL_LIBS`"
QT_CORE_LIB="$qt_corelibs" QT_CORE_LIB="$qt_corelibs"
else else
QT_CORE_LIB=`echo $qt_corelibs | tr ' ' '\n' | grep -e "^-l" | tr '\n' ' '` QT_CORE_LIB=`echo $qt_corelibs | tr ' ' '\n' | grep -e "^-l" | tr '\n' ' '`
@ -440,17 +450,17 @@ percent.target = %
percent.commands = @echo -n "\$(\$(@))\ " percent.commands = @echo -n "\$(\$(@))\ "
QMAKE_EXTRA_TARGETS += percent QMAKE_EXTRA_TARGETS += percent
EOF2 EOF2
qmake $lyx_test_qt_pro -o $lyx_test_qt_mak 1>/dev/null 2>&1 $qmake6 $lyx_test_qt_pro -o $lyx_test_qt_mak 1>/dev/null 2>&1
QT_INCLUDES=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak INCPATH | sed 's/-I\. //g'` QT_INCLUDES=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak INCPATH | sed 's/-I\. //g'`
qt_guilibs=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak LIBS` qt_guilibs=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak LIBS`
QT_LDFLAGS=`echo $qt_guilibs | tr ' ' '\n' | grep -e "^-L" | tr '\n' ' '` QT_LDFLAGS=`echo $qt_guilibs | tr ' ' '\n' | grep -e "^-L" | tr '\n' ' '`
if test -z "$QT_LDFLAGS"; then if test -z "$QT_LDFLAGS"; then
QT_LDFLAGS="-L`qmake -query QT_INSTALL_LIBS`" QT_LDFLAGS="-L`$qmake6 -query QT_INSTALL_LIBS`"
QT_LIB="$qt_guilibs" QT_LIB="$qt_guilibs"
else else
QT_LIB=`echo $qt_guilibs | tr ' ' '\n' | grep -e "^-l" | tr '\n' ' '` QT_LIB=`echo $qt_guilibs | tr ' ' '\n' | grep -e "^-l" | tr '\n' ' '`
fi fi
QTLIB_VERSION=`qmake -v | grep "Qt version" | sed -e 's/.*\([[0-9]]\.[[0-9]]*\.[[0-9]]\).*/\1/'` QTLIB_VERSION=`$qmake6 -v | grep "Qt version" | sed -e 's/.*\([[0-9]]\.[[0-9]]*\.[[0-9]]\).*/\1/'`
if test -z "$QT_LIB"; then if test -z "$QT_LIB"; then
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
else else