Commit Graph

1 Commits

Author SHA1 Message Date
Fabian Kosmale 96c1337aef Support QML type registration split: build system + tools integration
This change addresses the following issue:
- Module A wants to have an optional QML API without depending on
  declarative (e.g., because it has a C++ only API usable for Widgets
  based applications that normally would not link against declarative).
- Thus we add a module B with all the QML support (type registration,
  maybe additional types/functions/image providers).
- Currently, this would require to wrap every type from module A into
  QML_FOREIGN manually, adding large amounts of boilerplate.

To solve this, we extend qmltyperegistrar and the CMake API:
- qmltyperegistrar gains a new --extract option to generate a file with
  all QML_FOREIGN declarations. More precisely, it generates a header
  and source file; the source file includes the header and the moc
  generated file.
- We expose this in cmake via a new qt6_generate_foreign_qml_types
  function. That function takes two targets, the source library's target
  and the QML module's target. It then runs qmltyperegistrar on the
  source library, and adds the generated files to the QML module's
  target, and adds the proper dependencies between the targets.

The remaining step to achieve the goal of split registration is to
provide the QML registration macros in a separate header.

Task-number: QTBUG-92258
Change-Id: I51c4ef660ca7476b556b1991a6c76bbcad2c69af
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 15:56:59 +01:00