CMake warns about missing plugin targets when building Qt Quick project with "devel_qt6" pattern

I see no warnings when using Qt from official qt-online-installer.

I have installed system-wide development packages with

# zypper in -t pattern devel_qt6

As an example, for “qtquickcontrols2plugin” I see

> grep -r "qtquickcontrols2plugin" /usr/lib64/cmake/
/usr/lib64/cmake/Qt6QuickControls2/Qt6QuickControls2Targets.cmake:  _qt_qml_module_installed_plugin_target "Qt6::qtquickcontrols2plugin"
/usr/lib64/cmake/Qt6QuickControls2/Qt6QuickControls2Targets.cmake:  _qt_qml_module_plugin_target "qtquickcontrols2plugin"

while with qt-online-installer prefix

> grep -r "qtquickcontrols2plugin" 6.10.0/gcc_64/lib/cmake/
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginConfigVersion.cmake:include("${CMAKE_CURRENT_LIST_DIR}/Qt6qtquickcontrols2pluginConfigVersionImpl.cmake")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginConfig.cmake:    if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/Qt6qtquickcontrols2pluginDependencies.cmake")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginConfig.cmake:        include("${CMAKE_CURRENT_LIST_DIR}/Qt6qtquickcontrols2pluginDependencies.cmake")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginConfig.cmake:        set(qtquickcontrols2plugin_FOUND TRUE)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginConfig.cmake:    if(qtquickcontrols2plugin_FOUND)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginConfig.cmake:        include("${CMAKE_CURRENT_LIST_DIR}/Qt6qtquickcontrols2pluginTargets.cmake")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginConfig.cmake:        include("${CMAKE_CURRENT_LIST_DIR}/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets-relwithdebinfo.cmake:# Import target "Qt6::qtquickcontrols2plugin" for configuration "RelWithDebInfo"
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets-relwithdebinfo.cmake:set_property(TARGET Qt6::qtquickcontrols2plugin APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets-relwithdebinfo.cmake:set_target_properties(Qt6::qtquickcontrols2plugin PROPERTIES
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets-relwithdebinfo.cmake:  IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/qml/QtQuick/Controls/libqtquickcontrols2plugin.so"
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets-relwithdebinfo.cmake:list(APPEND _cmake_import_check_targets Qt6::qtquickcontrols2plugin )
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets-relwithdebinfo.cmake:list(APPEND _cmake_import_check_files_for_Qt6::qtquickcontrols2plugin "${_IMPORT_PREFIX}/qml/QtQuick/Controls/libqtquickcontrols2plugin.so" )
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets.cmake:foreach(_cmake_expected_target IN ITEMS Qt6::qtquickcontrols2plugin)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets.cmake:# Create imported target Qt6::qtquickcontrols2plugin
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets.cmake:add_library(Qt6::qtquickcontrols2plugin MODULE IMPORTED)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets.cmake:set_target_properties(Qt6::qtquickcontrols2plugin PROPERTIES
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets.cmake:  _qt_sbom_spdx_id "SPDXRef-Package-qtdeclarative-qt-plugin-qtquickcontrols2plugin"
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginTargets.cmake:file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/Qt6qtquickcontrols2pluginTargets-*.cmake")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:# Additional target information for Qt6qtquickcontrols2plugin
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:__qt_internal_promote_target_to_global_checked(Qt6::qtquickcontrols2plugin)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:get_target_property(_qt_imported_location Qt6::qtquickcontrols2plugin IMPORTED_LOCATION_RELWITHDEBINFO)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:get_target_property(_qt_imported_location_default Qt6::qtquickcontrols2plugin IMPORTED_LOCATION_${QT_DEFAULT_IMPORT_CONFIGURATION})
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:# Import target "Qt6::qtquickcontrols2plugin" for configuration "Release"
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:set_property(TARGET Qt6::qtquickcontrols2plugin APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:    set_property(TARGET Qt6::qtquickcontrols2plugin PROPERTY IMPORTED_LOCATION_RELEASE "${_qt_imported_location}")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:# Import target "Qt6::qtquickcontrols2plugin" for configuration "MinSizeRel"
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:set_property(TARGET Qt6::qtquickcontrols2plugin APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:    set_property(TARGET Qt6::qtquickcontrols2plugin PROPERTY IMPORTED_LOCATION_MINSIZEREL "${_qt_imported_location}")
6.10.0/gcc_64/lib/cmake/Qt6Qml/QmlPlugins/Qt6qtquickcontrols2pluginAdditionalTargetInfo.cmake:    set_property(TARGET Qt6::qtquickcontrols2plugin PROPERTY IMPORTED_LOCATION "${_qt_imported_location_default}")
6.10.0/gcc_64/lib/cmake/Qt6QuickControls2/Qt6QuickControls2Targets.cmake:  _qt_qml_module_installed_plugin_target "Qt6::qtquickcontrols2plugin"
6.10.0/gcc_64/lib/cmake/Qt6QuickControls2/Qt6QuickControls2Targets.cmake:  _qt_qml_module_plugin_target "qtquickcontrols2plugin"

Is this expected? Fedora provides “missing” files in " qt6-qtdeclarative-devel" package. Should I install packages in addition to"devel_qt6" pattern?

It appears that these files are explicitly deleted at File qt6-declarative.spec of Package qt6-declarative - openSUSE Build Service (lines 1043–1045)

# CMake files are not needed for plugins
rm -r %{buildroot}%{_qt6_cmakedir}/Qt6Qml/QmlPlugins
rm %{buildroot}%{_qt6_cmakedir}/*/*Plugin{Config,Targets}*.cmake

Is there a reason for that? Are CMake warnings about missing plugin targets expected to be somehow suppressed?

It has been this way for over 5 years. The subject of this topic says “CMake warns” but I do not see any single line of warning in your post. I guess you need to start with showing what you are doing together with messages and warnings it generates.

I have CMake project with Qt features initialized with

find_package(Qt6 REQUIRED COMPONENTS SerialPort Quick)
set(QT_FORCE_CMP0156_TO_VALUE NEW)
qt_standard_project_setup(REQUIRES 6.10)

target defined with “qt_add_executable” with corresponding “target_link_libraries” list containing “Qt6::SerialPort Qt6::Quick”

Here is an example of a warning I see on configuration

[cmake] CMake Warning at /usr/lib64/cmake/Qt6Qml/Qt6QmlMacros.cmake:4659 (message):
[cmake]   The qml plugin 'qtquickcontrols2plugin' is a dependency of
[cmake]   '********', but the link target it defines
[cmake]   (Qt6::qtquickcontrols2plugin) does not exist in the current scope.  The
[cmake]   plugin will not be linked.
[cmake] Call Stack (most recent call first):
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (qt6_import_qml_plugins)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (cmake_language)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:877 (_qt_internal_finalize_executable)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:846:EVAL:1 (qt6_finalize_target)
[cmake]   CMakeLists.txt:DEFERRED

VScode CMake integration tells me there are 27 such warnings about other plugins, like “qmlfolderlistmodelplugin”, “qtquickdialogsplugin”, …

The said target also has “qt_add_qml_module” with QML_FILES (qml/mjs) and SOURCES entries.

Here is minimal project to reproduce.

Should this be reported as package bug?

CMakeLists.txt

cmake_minimum_required(VERSION 4.0)

project(QtQuickIssue CXX)

find_package(Qt6 REQUIRED COMPONENTS Quick)

set(QT_FORCE_CMP0156_TO_VALUE NEW)

qt_standard_project_setup(REQUIRES 6.10)

qt_add_executable(QtQuickIssue main.cpp)
target_link_libraries(QtQuickIssue PRIVATE Qt6::Quick)
qt_add_qml_module(QtQuickIssue URI MainModule QML_FILES MainWindow.qml)

main.cpp

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char **argv) {
    QGuiApplication app(argc, argv); 
    QQmlApplicationEngine eng;
    eng.loadFromModule("MainModule", "MainWindow");
    return app.exec();
}

MainWindow.qml

import QtQuick

Window {
    visible: true
}

Generated warnings

[cmake] CMake Warning at /usr/lib64/cmake/Qt6Qml/Qt6QmlMacros.cmake:4659 (message):
[cmake]   The qml plugin 'qtquick2plugin' is a dependency of 'QtQuickIssue', but the
[cmake]   link target it defines (Qt6::qtquick2plugin) does not exist in the current
[cmake]   scope.  The plugin will not be linked.
[cmake] Call Stack (most recent call first):
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (qt6_import_qml_plugins)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (cmake_language)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:877 (_qt_internal_finalize_executable)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:846:EVAL:1 (qt6_finalize_target)
[cmake]   CMakeLists.txt:DEFERRED
[cmake] 
[cmake] 
[cmake] CMake Warning at /usr/lib64/cmake/Qt6Qml/Qt6QmlMacros.cmake:4659 (message):
[cmake]   The qml plugin 'qmlplugin' is a dependency of 'QtQuickIssue', but the link
[cmake]   target it defines (Qt6::qmlplugin) does not exist in the current scope.
[cmake]   The plugin will not be linked.
[cmake] Call Stack (most recent call first):
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (qt6_import_qml_plugins)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (cmake_language)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:877 (_qt_internal_finalize_executable)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:846:EVAL:1 (qt6_finalize_target)
[cmake]   CMakeLists.txt:DEFERRED
[cmake] 
[cmake] 
[cmake] CMake Warning at /usr/lib64/cmake/Qt6Qml/Qt6QmlMacros.cmake:4659 (message):
[cmake]   The qml plugin 'modelsplugin' is a dependency of 'QtQuickIssue', but the
[cmake]   link target it defines (Qt6::modelsplugin) does not exist in the current
[cmake]   scope.  The plugin will not be linked.
[cmake] Call Stack (most recent call first):
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (qt6_import_qml_plugins)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (cmake_language)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:877 (_qt_internal_finalize_executable)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:846:EVAL:1 (qt6_finalize_target)
[cmake]   CMakeLists.txt:DEFERRED
[cmake] 
[cmake] 
[cmake] CMake Warning at /usr/lib64/cmake/Qt6Qml/Qt6QmlMacros.cmake:4659 (message):
[cmake]   The qml plugin 'workerscriptplugin' is a dependency of 'QtQuickIssue', but
[cmake]   the link target it defines (Qt6::workerscriptplugin) does not exist in the
[cmake]   current scope.  The plugin will not be linked.
[cmake] Call Stack (most recent call first):
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (qt6_import_qml_plugins)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:799 (cmake_language)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:877 (_qt_internal_finalize_executable)
[cmake]   /usr/lib64/cmake/Qt6Core/Qt6CoreMacros.cmake:846:EVAL:1 (qt6_finalize_target)
[cmake]   CMakeLists.txt:DEFERRED

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.