Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
6.1.0 RC
-
None
Description
qmltyperegistrar takes in a JSON file that specifies, among other things, headers. The .cpp file that qmltyperegistrar generates has #include <someheader.h> statements for these headers. The JSON files can come from CMake if the target has autogen enabled, or from manual invocation. For the former, the cmake_automoc_parser takes the JSON files CMake generated and rewrites new files, in the process dropping the path from the headers. This means qmltyperegistrar doesn't know about the header's location.
The consequence of this is that when the generated .cpp file is added to the target, it needs the project to manually add the header's directory to the includes search path. For simple projects, this will often be just the target's source directory. Our examples seem to paper over this by adding a line like the following to their CMakeLists.txt:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Projects shouldn't be required to do this, and it won't be enough if they have headers in subdirectories anyway.
In theory, we start out having enough information to embed the full paths to headers in the .cpp files that qmltyperegistrar generates, but we discard that information. We should keep it and embed full paths in the generated .cpp files so that user projects don't need to do anything. Embedding the paths instead of automatically adding those paths to the header search path also means we don't potentially make the consuming project vulnerable to picking up same-named headers in different directories to what they might otherwise have been expecting.
Attachments
Issue Links
- blocks
-
QTBUG-114077 Package sub-folders generation doesn't work with QML argument
- Closed
- is duplicated by
-
QTBUG-131725 qt_add_qml_module should use source paths as is
- Closed
-
QTBUG-99653 qt_add_qml_module generates strange include directives
- Closed
- relates to
-
QTBUG-87221 Qt6's *_qmltyperegistrations.cpp generation breaks when using includes with folder names
- Closed
-
QTBUG-91265 Remove reliance on CMake-internal autogen files for cmake_automoc_parser
- Open