meta-qt5 / meta-qt5

QT5 layer for openembedded
MIT License
254 stars 327 forks source link

CMake configure using QtQuick fails because plugin detection was relaxed in Qt 5.15 #365

Open wdobbe opened 3 years ago

wdobbe commented 3 years ago

The NXP Yocto BSP is currently using the Zeus branches, but for meta-qt5 they recently switched to the master branch.

When I build and install the SDK for the Congatec QMX6 SoC, building an application that uses QtWebEngine via cmake fails with the output below. I tracked this down to a change in the QtQuick cmake config file:

Qt 5.13: file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Quick_*Plugin.cmake")

Qt 5.15

    # In Qt 5.15 the glob pattern was relaxed to also catch plugins not literally named Plugin.
    # Define QT5_STRICT_PLUGIN_GLOB or ModuleName_STRICT_PLUGIN_GLOB to revert to old behavior.
    if (QT5_STRICT_PLUGIN_GLOB OR Qt5Quick_STRICT_PLUGIN_GLOB)
        file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Quick_*Plugin.cmake")
    else()
        file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Quick_*.cmake")
    endif()

Because of that change the file /usr/lib/cmake/Qt5Quick/Qt5Quick_QSGVideoNodeFactory_EGL.cmake is now treated as a plugin.

I could fix it by reverting to the old (strict) plugin detection behaviour with a qtdeclarative_%.bbappend:

do_install_append() {
    #In Qt 5.15 the glob expression to find qtquick plugins was relaxed.
    #As a result, findPackage(QtQuick) fails with an error that 
    #file videoeglvideonode could not be found.
    #Revert back to old (strict) plugin detection.
    if [ -f ${D}/${libdir}/cmake/Qt5Quick/Qt5QuickConfig.cmake ]
    then
        sed -i -e '/^[ \t]*# In Qt 5.15 the glob pattern was relaxed/i set(QT5_STRICT_PLUGIN_GLOB ON)' ${D}/${libdir}/cmake/Qt5Quick/Qt5QuickConfig.cmake
    fi
}

I am not sure if we should do that be default or only for NXP i.MX[678] machines.

CMake error output:

CMake Error at /home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/cmake/Qt5Quick/Qt5QuickConfig.cmake:31 (message):
  The imported target "Qt5::Quick" references the file

     "/home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/plugins/videoeglvideonode"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/cmake/Qt5Quick/Qt5Quick_QSGVideoNodeFactory_EGL.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/cmake/Qt5Quick/Qt5QuickConfig.cmake:244 (_qt5_Quick_check_file_exists)
  /home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/cmake/Qt5Quick/Qt5Quick_QSGVideoNodeFactory_EGL.cmake:4 (_populate_Quick_plugin_properties)
  /home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/cmake/Qt5Quick/Qt5QuickConfig.cmake:253 (include)
  /home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/cmake/Qt5WebEngineCore/Qt5WebEngineCoreConfig.cmake:116 (find_package)
  /home/wdobbe/install/dynniq-yoctosdk/cortexa9hf/3.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/cmake/Qt5WebEngine/Qt5WebEngineConfig.cmake:116 (find_package)
  CMakeLists.txt:32 (find_package)

-- Configuring incomplete, errors occurred!
CTerasaGuF commented 2 years ago

IMHO the problem seems to be the following lines from https://github.com/meta-qt5/meta-qt5/blob/master/classes/qmake5_base.bbclass#L256

    # Replace resolved lib path with the lib name
    find ${D} -name "*.cmake" -exec \
        sed -i -e 's@/[^;]*/lib\([^;]*\)\.\(so\|a\)@\1@g' {} \;

It replaces the lib references with wrong entries for the Qt5Multimedia_QSGVideoNodeFactory_EGL.cmake and the Qt5Multimedia_QSGVivanteVideoNodeFactory.cmake.

You can see that the package's build directory contains correct versions and the image dir contains boggled versions. So teh install step does something to the NodeFactory cmake files The following .bbappend entry works for me, but does not fix the underlying problem.

# The "Replace resolved lib path with the lib name" of qtmake5_base.bbclass
# mangles with some cmake files. The fix in the bbappend does not help with
# anything. Redo the copy from the build dir.
do_install_append () {
    if [ -f "${B}/lib/cmake/Qt5Multimedia/Qt5Multimedia_QSGVideoNodeFactory_EGL.cmake" ]; then
        install -m 644 ${B}/lib/cmake/Qt5Multimedia/Qt5Multimedia_QSGVideoNodeFactory_EGL.cmake  ${D}${libdir}/cmake/Qt5Multimedia/Qt5Multimedia_QSGVideoNodeFactory_EGL.cmake
    fi
    if [ -f "${B}/lib/cmake/Qt5Multimedia/Qt5Multimedia_QSGVivanteVideoNodeFactory.cmake" ]; then
        install -m 644 ${B}/lib/cmake/Qt5Multimedia/Qt5Multimedia_QSGVivanteVideoNodeFactory.cmake  ${D}${libdir}/cmake/Qt5Multimedia/Qt5Multimedia_QSGVivanteVideoNodeFactory.cmake
    fi
}