Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93443

qmltyperegistrar generates .cpp files that need header search paths to be manually added

    XMLWordPrintable

Details

    • All

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtbuildsystem Qt Build System Team
              crscott Craig Scott
              Votes:
              14 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes