Make `qt_add_qml_module` generate #include <some_path/file_name.h>
-
Is there a way to make
qt_add_qml_module
generate#include <file_name.h>
directives as#include <some_path/file_name.h>
(where file_name.h is a header containingQML_ELEMENT
, for example)?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? Or even simply include with absolute path?IMHO: Adding every directory containing a header with
QML_ELEMENT
to include path is not a good idea.EDIT1:
C++ files generated with MOC include headers with relative paths like this:
#include "../../../../MyApp/Purchasing/inapp/inapppurchasebackend.h"
so, it is strange that
qt_add_qml_module
does not do the same. JSON should contain this relative file name probably, instead of"inputFile": "inapppurchasebackend.h",
inputFile
is used inqt-everywhere-src-6.2.2\qtdeclarative\src\qmltyperegistrar
, but I can't figure out at first glance where is it set. -
@Dmitriano said in Make `qt_add_qml_module` generate #include <some_path/file_name.h>:
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?