[Development] Enorcing QT_SKIP_AUTO_[QML_]PLUGIN_INCLUSION

Alexandru Croitor alexandru.croitor at qt.io
Mon Jul 3 16:59:55 CEST 2023



> On 3. Jul 2023, at 16:47, Lisandro Damián Nicanor Pérez Meyer <perezmeyer at gmail.com> wrote:
> 
> Now the question is: is the CMake file used to only check for it's presence or will designer fail to load the static file?

If the CMake file is present, but not loaded (via an explicit find_package call or transitively through another find_package call), building Designer will fail at cmake configure time.

That would happen in the hypothetical case where qttools/src/tools/designer/CMakeLists.txt has:

    target_link_libraries(Designer PRIVATE Qt6::QIconsPlugin)

If you set QT_SKIP_AUTO_PLUGIN_INCLUSION to ON, CMake will error out saying "unknown target Qt6::QIconsPlugin", even if the file exists and is installed as part of qt6-qtbase-dev.

Adding find_package(Qt6 COMPONENTS IconsPlugin) before the target_link_libraries call would fix it.

While I agree it's generally a good idea to be more granular and explicit with these kind of dependencies, e.g. to specify find_package calls only in subdirectories of targets that need them,
in practice CMake target / directory scoping rules often cause obscure issues. 

Which is why we autoload all plugins in the root CMakeLists.txt where the initial find_package(Qt6) call is done.

This provides ease of use for regular Qt builders (not distros) and avoids the cmake scoping issues.


More information about the Development mailing list