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

Inconsistent static linking of CMake-defined QML modules

XMLWordPrintable

    • Linux/X11, Windows

      Hello,
      static module linking for QML modules declared using the new CMake API is inconsistent between Linux (Manjaro) and Windows. Here is the overview:

      I have a project with the following structure:

      Project
       +-- CMakeLists.txt (root)
       +-- main.cpp
       +-- example
          +-- CMakeLists.txt (child)
          +-- main.qml

      Root CMakeLists defines a new executable using qt_add_executable. Child CMakeLists defines a QML module with qt_add_qml_module on target QmlModule. The executable is linked to the QmlModule target.

      On Linux, this project works as expected - calling QQmlApplicationEngine::load("qrc:/example/main.qml") launches the GUI correctly.

      On Windows, the project compiles, but fails at runtime with the following error:
      qrc:/example/main.qml: No such file or directory

      The official documentation gives an example linking not to the module target, but to the autogenerated plugin (link). This approach works on both platforms.

      I don't know which platform displays the correct behavior, but I think it should be consistent.

      I have attached a MRE project to test this issue.

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

            qtbuildsystem Qt Build System Team
            mbugdol Michał Bugdoł
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes