How to consume public header files of a generic qml_module in a project specific qml_module
-
Hi!
We have a bit more complex setup with a generic library that defines (multiple) qml_modules. These qml_modules are then consumed in projects. Projects are again separated into multiple qml_modules. The problem arises while we wanted to transition to QmlProject files from CMake (as the Qt for MCUs CMake API is deprecated). The project specific qml_module has C++ types that need to be used in Qml, hence we define aInterfaceFiles
node in the QmlProject like the following:InterfaceFiles { files: [ "include/path/to/a/InterfaceHeader.h" ] MCU.qmlImports: [ "com.company.generic.component" ] }
The compiler fails to resolve header includes in
InterfaceHeader.h
as the qmlprojectgenerator only gets CMakeINCLUDE_DIRECTORIES
of the CMake targets of the project feature qml_module passed as the--include-dirs
parameter. The feature lib (created withqul_add_target(TARGET_NAME QML_PROJECT feature.qmlproject)
does link to the generic qml_module with atarget_link_libraries()
call but this is too late for the internal workings of thequl_add_target
macro.Somehow the QmlProject is missing a way to tell it which other qml_modules need to be linked/considered. The
qul_add_target
macro at some point internally is only evaluating the directINCLUDE_DIRECTORIES
which does not include the include directories of transitive dependencies.Here is another short overview of the structure:
* generic-library - output: qml_module * project * feature-a - defines qml_module - depends on qml_module of generic-library - ERROR: the interface header files of this of this qml_module are unable to include headers of the generic-library when using .qmlproject files. * feature-xxx - defines qml_module - depends on qml_module of generic-library - additionally might depend on another feature of the project * project-lib - depends on all features * project-app - depends on project-lib
Thx,
Andi