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

qt_target_qml_sources cannot be subdir of qt_add_qml_module

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8
    • Build System: CMake
    • None

    Description

      I am trying to use qt_add_qml_module command while placing QML sources in a sub-folder with its own CMakeLists file. In the view-folders CMakeLists:

      qt_add_library(MainModule STATIC)
      qt_add_qml_module(MainModule
          URI main_module
          VERSION 1.0
          QML_FILES
              Main_Page.qml
      )
      add_subdirectory(submodule) 

      In the sub-folders CMakeLists:

      qt_target_qml_sources(MainModule
          QML_FILES
              Sub_Page.qml
      ) 

      However, it seems like I am missing something as the build is unsuccessful (GCC compiler) given the following error.

      <project_folder>\modularMinQml\min_qml_module\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug\view\submodule\.rcc\qmlcache\MainModule_Sub_Page_qml.cpp:-1: error: <project_folder>/modularMinQml/min_qml_module/build/Desktop_Qt_6_6_3_MinGW_64_bit-Debug/view/submodule/.rcc/qmlcache/MainModule_Sub_Page_qml.cpp: No such file or directory 

      It worth noting that the project runs smoothly with qt_target_qml_sources written in the same CMakeLists as qt_add_qml_module.

      A minimal project regarding the problem is available at: minimal_qml_module where the structure tree is as follows

      {{}}

      D:.
      │   CMakeLists.txt
      │
      ├───main
      │       CMakeLists.txt
      │       header.h
      │       main.cpp
      │
      └───view
          │   CMakeLists.txt
          │   Main_Page.qml
          │
          └───submodule
                  CMakeLists.txt
                  Sub_Page.qml

       

      Any help would be appreciated.

      copy from
      https://stackoverflow.com/questions/78816202/how-to-use-qt-target-qml-sources-from-a-subdirectory-of-qt-add-qml-module-fo

      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
              jiu shanheng jiu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes