Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86500

[Linux] Building a basic QML app through CMake with Qt 6.0.0 snapshots fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 6.0
    • Build System: CMake
    • None

    Description

      Referenced snapshots: 1(June 15th), 2(June 25th), 3(6.0.0-202008280958, August 28th)

      The basic app example(created to see how to solve the dependencies issue),

      ok for Qt 6.0.0 public snapshot 1, broken on snapshots 2 && 3:

      https://github.com/lilianmoraru/qt6-basic-example

       

      In Qt 5, XCB dependencies would be compiled from internal sources(`qtbase`), thus avoiding to propagate that dependency to the user.

      In Qt 6, there seems to be a regression and the user has to install the following dependencies(Ubuntu/Debian example) in order to compile the basic example app:

      Qt 6.0.0 public snapshot 1:

      libgl1-mesa-dev libvulkan-dev libxcb-xinput-dev libxcb-xinerama0-dev

      Qt 6.0.0 public snapshots 2 && 3:

      libgl1-mesa-dev libvulkan-dev libxcb-xinput-dev libxcb-xinerama0-dev  libxkbcommon-dev libxkbcommon-x11-dev

      "libgl1-mesa-dev" was also required for Qt 5(after installing it, to create any GUI, you would need to install that dependency manually) - I think that is somewhat accepted now(expecting the same situation to be for `libvulkan-dev` but not for XCB which is available inside `qtbase`).

       

      After installing Qt 6 and manually tracking and installing all of these dependencies(my guess is it that other modules would require more dependencies tracking), the user hits the CMake target issues:

      • The targets cannot find other targets on which these depend, ex:
        Qt::Quick cannot find Qt::OpenGL and XKB::XKB or Qt::Quick cannot find Qt::Qml without Qt::QmlModels
        Usually a config file searches for it's own targets, in this example, QtQuickConfig.cmake would run `find_dependency(QtOpenGL)`(not sure if this is the exact config) and find it's own `Qt::OpenGL` target, not forcing the user to do the manual tracking of the dependencies.
        Example: https://raw.githubusercontent.com/abseil/abseil-cpp/master/CMake/abslConfig.cmake.in
      • Some targets should use `target_link_libraries(... PRIVATE ...)` to hide the internal dependencies and not expose the details to the user: XKB::XKB is not exposed to the user through the public API, thus, this should be linked using the "PRIVATE" keyword.

       

      The final solution to compile the basic QML app on Linux(Ubuntu/Debian), on August 28th snapshot, looks like this:

      Additional Ubuntu dependencies required to be installed by the client:

      sudo apt install libgl1-mesa-dev libvulkan-dev libxcb-xinput-dev libxcb-xinerama0-dev libxkbcommon-dev libxkbcommon-x11-dev
      

      CMake file for the QML app:

      cmake_minimum_required(VERSION 3.15)
      
      project(qtquick LANGUAGES CXX)
      
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)
      
      # Missing XKBConfig.cmake/FindXKB.cmake
      include(/home/lilian/Downloads/FindXKB.cmake) # https://raw.githubusercontent.com/KDE/kwin/master/cmake/modules/FindXKB.cmake
      
      find_package(X11 REQUIRED)
      find_package(Qt6 CONFIG COMPONENTS Core Quick Qml QmlModels OpenGL REQUIRED)
      
      add_executable(qtquick
        src/main.cpp
        qml.qrc
      )
      
      target_compile_definitions(qtquick
        PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
      target_link_libraries(qtquick
        PRIVATE Qt::Core Qt::Quick)
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              jbornema Joerg Bornemann
              lilian.moraru Lilian A. Moraru
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes