Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.6.1, 6.7.0 Beta3, 6.8
-
Linux (Manjaro)
Description
Hello,
this issue occurs with the CMake API for QML modules. I've encountered the error when trying to create a QML module in the subdirectory of the module's target. Here are the steps to reproduce the issue:
First, I've created a new project with the following directory structure:
Project
+-- CMakeLists.txt (root)
+-- main.cpp
+-- gui
+-- CMakeLists.txt (child)
+-- Main.qml
Inside the root CMakeLists, I've called qt_standard_project_setup and created a new executable (app):
qt_add_executable(app main.cpp)
Then I've created a new QML module (example) on target app inside the child CMakeLists:
qt_add_qml_module(app
URI example
QML_FILES Main.qml
)
When I run CMake, it fails on step Automatic QML type registration for target app with the following output:
FAILED: app_qmltyperegistrations.cpp qml/example/app.qmltypes build/app_qmltyperegistrations.cpp build/qml/example/app.qmltypes
cd build/qml && /usr/lib/qt6/qmltyperegistrar --generate-qmltypes=build/qml/example/app.qmltypes --import-name=example --major-version=254 --minor-version=254 @build/qmltypes/app_foreign_types.txt -o build/app_qmltyperegistrations.cpp build/meta_types/qt6app_debug_metatypes.json && /usr/bin/cmake -E make_directory build/.generated && /usr/bin/cmake -E touch build/.generated/app.qmltypes
Error 5 while parsing build/meta_types/qt6app_debug_metatypes.json: illegal value
ninja: build stopped: subcommand failed.
I've simplified the build directory path to build and bolded the actual error. The qt6app_debug_metatypes.json file is empty (size=0).
If I instead move the Main.qml file to root directory and move the QML module declaration to root CMakeLists, everything works as intended. Interestingly, if I then go back to the erroneous directory structure, CMake works correctly until I remove the build folder, after which it will again raise the error described above.
Creating a new target using qt_add_library, making it the QML module target and linking the library to root executable works, but it isn't what I'm aiming for.
I am using CMake 3.28.1 and Qt 6.6.1 on Linux (Manjaro).
Attachments
Issue Links
- relates to
-
QTBUG-107130 qmlcache problem when referencing Qml files outside of current directory tree
- Reported
-
QTBUG-123574 qt_generate_foreign_qml_types can't extract metatypes for target created in different directory scope
- Open