[Interest] creating QML module in a subdirectory of backing target
Stefan Seefeld
stefan at seefeld.name
Thu Aug 15 14:39:30 CEST 2024
Thanks Alexandru !
I was indeed toying around with QML_FOREIGN to overcome some of those
limits, but, as I reported in a separate mail yesterday, I also encountered
problems, where a "foreign" type from a separate library generated
```Warning: Refusing to generate non-lowercase name "A" for unknown foreign
type```
without giving me any other hint at what had caused this. (Trying to
reverse-engineer by looking through
https://codebrowser.dev/qt6/qtdeclarative/src/qmltyperegistrar/qqmltypesclassdescription.cpp.html
it appears as if some of the (meta-)data about type A isn't accessible to
Qt's type compiler. But even that is a bit obscure. I thought `QML_FOREIGN`
was specifically designed for this use case !?
Thanks,
On Thu, Aug 15, 2024 at 4:38 AM Alexandru Croitor <alexandru.croitor at qt.io>
wrote:
> Hi,
>
> As far as I know this currently doesn't work, and is a variation of the
> following bug report:
> https://bugreports.qt.io/browse/QTBUG-122702
>
> After a very quick scan, I believe the docs don't mention this limitation.
>
> The happy path for qml modules is to have the library / executable created
> in the same subdirectory as the call to qt_add_qml_module.
>
> If the qml module needs to be separate from the backend C++ code, i
> believe the suggested way is to create two libraries:
> one just for the C++ code, and another for the Qml code which references
> the types from the other library via QML_FOREIGN,
> as described at https://doc.qt.io/qt-6/qt-generate-foreign-qml-types.html
>
> But maybe someone from the qml team can offer better advice.
>
> > On 14. Aug 2024, at 14:04, Stefan Seefeld <stefan at seefeld.name> wrote:
> >
> > hello,
> >
> > in a large CMake / Qt project of mine, I'm building a (shared) library
> in some directory `A`.
> > Now I want to add a QML module for that, but due to various constraints
> want to do that in a subdirectory `A/qml`.
> > That is, I have
> >
> > A/
> > ├── CMakeLists.txt
> > ├── qml
> > │ ├── CMakeLists.txt
> >
> > where `A/CMakeLists.txt` calls `addLibrary(A ...)`, and
> `A/qml/CMakeLists.txt` calls `qt_add_qml_module(A ...)`
> >
> > This eventually bails with the error
> >
> > ```
> > ... No rule to make target '.../A/A_qmltyperegistrations.cpp`, needed by
> 'CMakeFiles/A.dir/a_qmltyperegistrations.cpp.o'
> > ```
> > If I merge the definition of `qml_add_qml_module` in the outer
> CMakeLists.txt file, everything is compiling fine.
> > Am I missing something ? Is this is known limitation of the build logic ?
> >
> > Thanks for any hints,
> >
> > --
> > ...ich hab' noch einen Koffer in Berlin...
> >
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > https://lists.qt-project.org/listinfo/interest
>
>
--
...ich hab' noch einen Koffer in Berlin...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240815/042169d2/attachment.htm>
More information about the Interest
mailing list