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

Static Qt builds add duplicate plugin import sources every time find_package() is called on a module



    • Platform/s:
    • Commits:
      f0ccdbb439ecce01e63b6c6947da7f56e50ecf9f (qt/qtbase/dev)


      When pulling in a module that has plugins (e.g. Gui) with find_package(), part of the CMake code path that gets invoked comes from the qtbase/cake/QtPlugins.cmake.in template. That code generates C++ sources that call the Q_IMPORT_PLUGIN macro for each associated plugin (e.g. GIF, ICO, Jpeg, etc.). These sources are added as INTERFACE sources to the module target. In a project where there is more than one such call to find_package() that brings in the module, it doesn't check if it has already added these sources and will generate and add another copy.

      In the extreme case where you are building qtbase and have tests and examples enabled, there are many such calls to find_package(). This results in a blowout in files to be generated, compiled and linked for each target that links against a module like Gui. The giveaway symptom is a blow-out in CMake generation time and a huge build.ninja file.

      The QtPlugins.cmake.in file needs to ensure it only generates and adds the plugin import sources once for a given module target. Note also that the module target might or might not be global. When building Qt from source, the target will be global, but when building against an installed Qt, the target will have local scope (find_package() creates imported targets which have local scope by default - this is standard CMake behavior). This means there could be multiple local targets in different scopes for the same module, so the mechanism used to track whether the generated files have been added yet needs to be recorded on the module target itself somehow.


        For Gerrit Dashboard: QTBUG-90465
        # Subject Branch Project Status CR V



            crscott Craig Scott
            crscott Craig Scott
            0 Vote for this issue
            1 Start watching this issue



                Gerrit Reviews

                There are no open Gerrit changes