Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Make `qt_add_qml_module` generate #include <some_path/file_name.h>
Is there a way to make
#include <file_name.h>directives as
#include <some_path/file_name.h>(where file_name.h is a header containing
QML_ELEMENT, for example)?
If no, why not to add a parameter like ROOT_INCLUDE_DIR to
qt_add_qml_modulein future QT releases and generate
#includedirectives with the paths relative to it? Or even simply include with absolute path?
IMHO: Adding every directory containing a header with
QML_ELEMENTto include path is not a good idea.
C++ files generated with MOC include headers with relative paths like this:
so, it is strange that
qt_add_qml_moduledoes not do the same. JSON should contain this relative file name probably, instead of
inputFileis used in
qt-everywhere-src-6.2.2\qtdeclarative\src\qmltyperegistrar, but I can't figure out at first glance where is it set.
Is there a way to make qt_add_qml_module generate #include <file_name.h> directives as #include <some_path/file_name.h>
Not according the documentation.
If no, why not to add a parameter like ROOT_INCLUDE_DIR to qt_add_qml_module in future QT releases and generate #include directives with the paths relative to it?
Feel free to provide a patch.
@Christian-Ehrlicher I am not sure, probably the patch is hard for me, but while investigating the sources I found something that is strange enough to be probably reported as a bug, see EDIT1. (while formally it is not a bug of cause)
I don't see why this should be a bug. Moc creates a header file which contains a path to it's header it needs. qt_add_qml_module() generates a package so why should there be relative paths to some others which may be different on other machines where you use the package?
@Christian-Ehrlicher My understanding is that both MOC and
qt_add_qml_module()generate internal C++ files that are not compiled by others who use the module (or package). Is my understanding correct?