From 134d090f3d98817c4778b27aaae5d0497193b637 Mon Sep 17 00:00:00 2001 From: pengfeixx <63588879+pengfeixx@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:32:44 +0800 Subject: [PATCH] fix: explicitly find Qt6 GuiPrivate component on Qt >= 6.10 Since Qt 6.10, private module targets such as Qt6::GuiPrivate are shipped as standalone CMake packages (Qt6GuiPrivateConfig.cmake) and are no longer auto-created by Qt6GuiTargets.cmake when the main module is found. As a result, linking Qt6::GuiPrivate without explicitly finding the private component fails at configure time: CMake Error at CMakeLists.txt (target_link_libraries): Target "dde-device-formatter" links to: Qt6::GuiPrivate but the target was not found. This broke packaging on the Qt 6.12 build server (cmake configure step of dh_auto_configure exits with code 1), same as deepin-screensaver which was fixed the same way in linuxdeepin/deepin-screensaver#139. After the main find_package(Qt6 ...) call, explicitly find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) when the detected Qt version is >= 6.10. On Qt <= 6.9 (including the 6.8 baseline) nothing changes: the gate evaluates false and the target is still auto-created by Qt6GuiTargets.cmake. Verified: - with qt6-base-dev 6.12.0-1 the Qt6GuiPrivate CMake package ships Qt6GuiPrivateTargets.cmake defining Qt6::GuiPrivate (INTERFACE IMPORTED), which this explicit lookup now consumes - against Qt 6.8.0 the version gate evaluates false and configure passes all Qt find_package steps unchanged --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e473acb..6c5521a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,12 @@ if (QT_VERSION_MAJOR MATCHES 5) list(APPEND QT_COMPONENTS X11Extras) endif() find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QT_COMPONENTS} REQUIRED) + +# Qt 6.10 起,私有模块目标(如 Qt6::GuiPrivate)拆分为独立的 CMake 包,不再随主模块自动创建,需显式查找; +# 更早版本该目标由 Qt6GuiTargets.cmake 自动创建,无需额外处理 +if (QT_VERSION_MAJOR MATCHES 6 AND Qt6_VERSION VERSION_GREATER_EQUAL 6.10) + find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) +endif() find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget Gui REQUIRED) find_package(PkgConfig REQUIRED) pkg_check_modules(UDISKS2QT REQUIRED IMPORTED_TARGET udisks2-qt${QT_VERSION_MAJOR})