Skip to content

fix: explicitly find Qt6 GuiPrivate component on Qt >= 6.10 - #52

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/qt6.10-guiprivate-cmake
Nov 6, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/qt6.10-guiprivate-cmake

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Building dde-device-formatter 1.5.11 on the Qt 6.12 build server fails at the cmake configure step:

CMake Error at CMakeLists.txt:120 (target_link_libraries):
  Target "dde-device-formatter" links to:
    Qt6::GuiPrivate
  but the target was not found.

Since Qt 6.10, private module targets such as Qt6::GuiPrivate are shipped as standalone CMake packages (Qt6GuiPrivateConfig.cmake, installed by qt6-base-dev under cmake/Qt6GuiPrivate/) and are no longer auto-created by Qt6GuiTargets.cmake when the main module is found. Linking the private target without explicitly finding the private component therefore fails at configure time.

Same failure and same fix pattern as deepin-screensaver: linuxdeepin/deepin-screensaver#139

Changes

  • After the main find_package(Qt${QT_VERSION_MAJOR} ...) call, explicitly find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) when the detected Qt version is >= 6.10
  • On Qt <= 6.9 (including the current 6.8 baseline) nothing changes: the version gate evaluates false and Qt6::GuiPrivate is still auto-created by Qt6GuiTargets.cmake

Testing

  • Verified with qt6-base-dev 6.12.0-1 package contents: cmake/Qt6GuiPrivate/Qt6GuiPrivateTargets.cmake exists and defines add_library(Qt6::GuiPrivate INTERFACE IMPORTED) — the explicit lookup introduced here consumes exactly this package
  • Verified against Qt 6.8.0: the version gate evaluates false, configure passes all Qt find_package steps unchanged (behavior identical to before this change)

Summary by Sourcery

Bug Fixes:

  • Fix Qt 6.10 and newer configuration failures by explicitly locating the standalone Qt6 GuiPrivate component before linking against it.

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
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates CMake dependency discovery so builds using Qt 6.10+ can resolve the separately packaged Qt6::GuiPrivate target, while retaining compatibility with older Qt versions.

Flow diagram for Qt private component discovery

flowchart TD
    A["find_package(Qt${QT_VERSION_MAJOR})"] --> B{"Qt version is 6.10 or newer?"}
    B -->|Yes| C["find_package(Qt6 REQUIRED COMPONENTS GuiPrivate)"]
    B -->|No| D["Qt6::GuiPrivate auto-created by Qt6GuiTargets.cmake"]
    C --> E["Qt6::GuiPrivate available"]
    D --> E
    E --> F["Configure target_link_libraries"]
Loading

File-Level Changes

Change Details Files
Explicitly discovers the Qt 6 GuiPrivate CMake component on Qt 6.10 and newer.
  • Adds a version-gated find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) after the primary Qt component lookup.
  • Preserves existing behavior for Qt 5 and Qt 6.8–6.9, where GuiPrivate is provided by the main Qt targets package.
CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交在 CMakeLists.txt 中添加了 Qt 6.10+ 显式查找 GuiPrivate 组件的条件逻辑, 修复了 Qt 6.10 起私有模块目标拆分为独立 CMake 包后的构建兼容性问题。语法逻辑正确, 代码质量高(注释清晰、结构合理),无性能影响,无安全漏洞。三类检查(AI 四维度分析、 启发式扫描、OCR 审查)结果一致,均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

# 当前代码已为最佳实践,无需修改。 # 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()

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, pengfeixx

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pengfeixx

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit a7a3843 into linuxdeepin:master Nov 6, 2026
17 checks passed
@pengfeixx
pengfeixx deleted the fix/qt6.10-guiprivate-cmake branch November 6, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants