From 075f156c35a79fb485a62d5e02ccc16dd4d61277 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 6 Oct 2024 21:07:58 +0200 Subject: [PATCH] test/cli/runtests.sh: added support for Qt6 package config --- test/cfg/qt.cpp | 12 ++++++++++-- test/cfg/runtests.sh | 13 ++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index 42bcd03e99e..4eec2f6b20d 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,11 @@ #include #include +// TODO: this is actually avilable via Core5Compat but I could not get it to work with pkg-config +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#include +#endif + #include int ignoredReturnValue_QSize_height(const QSize &s) @@ -323,6 +327,7 @@ QList::iterator QList3() return it; } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void QLinkedList1() { // cppcheck-suppress unreadVariable @@ -359,6 +364,7 @@ QLinkedList::iterator QLinkedList3() // cppcheck-suppress returnDanglingLifetime return it; } +#endif void QStringList1(QStringList stringlistArg) { @@ -569,11 +575,13 @@ void MacroTest2_test() QByteArray ba = str.toLatin1(); printf(ba.data()); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #ifndef QT_NO_DEPRECATED str = MacroTest2::trUtf8("test2"); ba = str.toLatin1(); printf(ba.data()); #endif +#endif } void MacroTest3() @@ -617,7 +625,7 @@ void validCode(int * pIntPtr, QString & qstrArg, double d) if (qstr1.length() == 1) {} } if (qstr1.length() == 1) {} else { - qstr1.remove(1); + qstr1.remove(1, 0); if (qstr1.length() == 1) {} } } diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index c1083d4e769..f6094a62651 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -107,10 +107,17 @@ function gnu_fn { # qt.cpp function qt_fn { if [ $HAS_PKG_CONFIG -eq 1 ]; then - QTCONFIG=$(get_pkg_config_cflags Qt5Core Qt5Test Qt5Gui) + # TODO: check syntax with Qt5 and Qt6? + QTCONFIG=$(get_pkg_config_cflags Qt6Core Qt6Test Qt6Gui) + if [ -z "$QTCONFIG" ]; then + QTCONFIG=$(get_pkg_config_cflags Qt5Core Qt5Test Qt5Gui) + QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt5Core Qt5Test Qt5Gui) + [[ $QTBUILDCONFIG =~ (^|[[:space:]])reduce_relocations($|[[:space:]]) ]] && QTCONFIG="${QTCONFIG} -fPIC" + else + QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt6Core Qt6Test Qt6Gui) + QTCONFIG="${QTCONFIG} -fPIC" + fi if [ -n "$QTCONFIG" ]; then - QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt5Core Qt5Test Qt5Gui) - [[ $QTBUILDCONFIG =~ (^|[[:space:]])reduce_relocations($|[[:space:]]) ]] && QTCONFIG="${QTCONFIG} -fPIC" # TODO: get rid of the error enabling/disabling? set +e echo -e "#include " | ${CXX} "${CXX_OPT[@]}" ${QTCONFIG} -x c++ -