Skip to content

fix: explicitly find Qt6 private components on Qt >= 6.10 - #256

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/qt6.12-private-targets
Nov 10, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/qt6.12-private-targets

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Building deepin-diskmanager 6.0.28 on the Qt 6.12 build server fails at the cmake configure step:

CMake Error at application/CMakeLists.txt:91 (target_link_libraries):
  Target "deepin-diskmanager" links to:
    Qt6::WidgetsPrivate
  but the target was not found.

Since Qt 6.10, private module targets are shipped as standalone CMake packages (Qt6WidgetsPrivateConfig.cmake, installed by qt6-base-dev under cmake/Qt6WidgetsPrivate/) and are no longer auto-created by the main module's Targets.cmake. Both usages in application/CMakeLists.txt are affected:

  • target_link_libraries(... Qt6::WidgetsPrivate ...) — hard configure error (the reported failure)
  • target_include_directories(... Qt6::GuiPrivate ...) — silently degrades to a literal string on 6.12, losing the private header include paths (compile failure later)

Same failure family and same fix pattern as linuxdeepin/deepin-screensaver#139 and linuxdeepin/dde-device-formatter#52.

Solution

After the main find_package(Qt...) call, explicitly find_package(Qt6 REQUIRED COMPONENTS WidgetsPrivate GuiPrivate) gated by Qt6_VERSION >= 6.10. On Qt <= 6.9 (including the 6.8 baseline) the version gate evaluates false and the targets are still auto-created — behavior unchanged.

Testing

  • Verified with qt6-base-dev 6.12.0-1 package contents: cmake/Qt6WidgetsPrivate/Qt6WidgetsPrivateTargets.cmake:69 and cmake/Qt6GuiPrivate/Qt6GuiPrivateTargets.cmake:69 both define add_library(Qt6::... INTERFACE IMPORTED) — exactly the packages this explicit lookup consumes
  • Against Qt 6.8.0: the version gate evaluates false, configure passes all Qt find_package steps unchanged (verified on host)
  • Same pattern previously runtime-validated on the Qt 6.12 build server by deepin-screensaver#139

Summary by Sourcery

Fix CMake configuration for Qt 6.10 and newer by explicitly finding the private Qt Widgets and Gui components.

Bug Fixes:

  • Ensure Qt 6.10 and newer builds can resolve the WidgetsPrivate and GuiPrivate CMake targets during configuration.

Build:

  • Update CMake configuration to explicitly locate Qt private components on Qt 6.10 and newer while preserving compatibility with older Qt 6 versions.

@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Explicitly find Qt 6.10+ private components so the application can resolve the WidgetsPrivate and GuiPrivate targets while preserving older Qt behavior.

  • application/CMakeLists.txt L28-33

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="application/CMakeLists.txt" line_range="31" />
<code_context>
+# Qt 6.10 起,私有模块目标(如 Qt6::WidgetsPrivate/GuiPrivate)拆分为独立 CMake 包,
+# 不再随主模块查找自动创建,需显式查找;更早版本由各 Targets.cmake 自动创建
+if (QT_VERSION_MAJOR MATCHES 6 AND Qt6_VERSION VERSION_GREATER_EQUAL 6.10)
+    find_package(Qt6 REQUIRED COMPONENTS WidgetsPrivate GuiPrivate)
+endif()
+
</code_context>
<issue_to_address>
**Private headers remain unavailable**

When configuring with Qt 6.10 or newer and compiling code in an earlier or sibling directory that needs Qt GUI private headers, `find_package` creates the private targets in the application directory, so earlier and sibling directories cannot use them; meanwhile, `target_include_directories` treats `Qt6::GuiPrivate` as a directory string instead of applying its interface include paths. Compilation fails to find the private headers.

Make the private targets available to all consuming directories and link the appropriate private target to each consumer instead of passing it to `target_include_directories`.

Also at `application/CMakeLists.txt:32`.
</issue_to_address>

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

# Qt 6.10 起,私有模块目标(如 Qt6::WidgetsPrivate/GuiPrivate)拆分为独立 CMake 包,
# 不再随主模块查找自动创建,需显式查找;更早版本由各 Targets.cmake 自动创建
if (QT_VERSION_MAJOR MATCHES 6 AND Qt6_VERSION VERSION_GREATER_EQUAL 6.10)
find_package(Qt6 REQUIRED COMPONENTS WidgetsPrivate GuiPrivate)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Private headers remain unavailable

When configuring with Qt 6.10 or newer and compiling code in an earlier or sibling directory that needs Qt GUI private headers, find_package creates the private targets in the application directory, so earlier and sibling directories cannot use them; meanwhile, target_include_directories treats Qt6::GuiPrivate as a directory string instead of applying its interface include paths. Compilation fails to find the private headers.

Make the private targets available to all consuming directories and link the appropriate private target to each consumer instead of passing it to target_include_directories.

Also at application/CMakeLists.txt:32.

Prompt for AI agents
In `application/CMakeLists.txt` at line 31:

**Private headers remain unavailable**

When configuring with Qt 6.10 or newer and compiling code in an earlier or sibling directory that needs Qt GUI private headers, `find_package` creates the private targets in the application directory, so earlier and sibling directories cannot use them; meanwhile, `target_include_directories` treats `Qt6::GuiPrivate` as a directory string instead of applying its interface include paths. Compilation fails to find the private headers.

Make the private targets available to all consuming directories and link the appropriate private target to each consumer instead of passing it to `target_include_directories`.

Also at `application/CMakeLists.txt:32`.

1. Qt 6.10 splits private module targets into standalone CMake
   packages, so Qt6::WidgetsPrivate/GuiPrivate are no longer
   auto-created by the main module's Targets.cmake
2. Linking Qt6::WidgetsPrivate now fails at configure time on the
   Qt 6.12 build server: Target "deepin-diskmanager" links to
   Qt6::WidgetsPrivate but the target was not found
3. GuiPrivate in target_include_directories silently degrades to a
   literal string on 6.12, losing private header paths; find it too
4. Gate behind Qt6_VERSION >= 6.10; Qt <= 6.9 (incl. 6.8 baseline)
   keeps the auto-created targets, behavior unchanged

Log: Fixed diskmanager configure failure on Qt 6.12 caused by
private module targets being split into standalone CMake packages

Influence:
1. Configure deepin-diskmanager against Qt 6.12, cmake passes
2. Verify private widget/gui headers still resolve at compile time
3. On Qt 6.8 confirm configure and build behavior unchanged

fix: 显式查找 Qt6 私有组件以适配 Qt 6.10+

1. Qt 6.10 将私有模块目标拆分为独立 CMake 包,
   Qt6::WidgetsPrivate/GuiPrivate 不再随主模块查找自动创建
2. Qt 6.12 服务器上链接 Qt6::WidgetsPrivate 在 configure 阶段
   失败:Target "deepin-diskmanager" links to Qt6::WidgetsPrivate
   but the target was not found
3. target_include_directories 中的 GuiPrivate 在 6.12 下退化为
   普通字符串,丢失私有头文件路径,一并显式查找
4. 以 Qt6_VERSION >= 6.10 门禁;Qt <= 6.9(含 6.8 基线)保持
   自动创建行为不变

Log: 修复磁盘管理在 Qt 6.12 下因私有模块目标拆分导致的
configure 失败

Influence:
1. 在 Qt 6.12 环境配置磁盘管理,cmake 通过
2. 验证编译期私有 widget/gui 头文件路径仍正确解析
3. 在 Qt 6.8 环境确认 configure 与构建行为不变
@pengfeixx
pengfeixx force-pushed the fix/qt6.12-private-targets branch from a1f0539 to e152df4 Compare November 10, 2026 02:06
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次变更为 CMake 构建配置适配 Qt 6.10 私有模块拆分的兼容性修复,语法正确、逻辑清晰、注释完整,无安全漏洞,四维度全部通过。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例


本报告由 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 5c09416 into linuxdeepin:master Nov 10, 2026
16 checks passed
@pengfeixx
pengfeixx deleted the fix/qt6.12-private-targets branch November 10, 2026 02:19
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