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.
The generated .cpp files are the responsibility of CACHEGEN. So all you need to do is specifying NO_CACHEGEN and it goes well