Skip to content

Conversation

@felixonmars
Copy link
Member

@felixonmars felixonmars commented Jan 19, 2026

Fixes the following error on Arch:

CMake Error at src/dbus/CMakeLists.txt:31 (target_link_libraries):
  Target "dde_am_dbus" links to:

    Qt::WaylandClientPrivate

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.



-- Generating done (0.1s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

Summary by Sourcery

Build:

  • Update Qt6 find_package components list to include WaylandClientPrivate so CMake can resolve the dde_am_dbus linkage.

Fixes the following error on Arch:

```
CMake Error at src/dbus/CMakeLists.txt:31 (target_link_libraries):
  Target "dde_am_dbus" links to:

    Qt::WaylandClientPrivate

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.



-- Generating done (0.1s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
```
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 19, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Extends the Qt6 CMake dependency list to explicitly require the private Wayland client component so that the dde_am_dbus target can link against Qt::WaylandClientPrivate without configuration failures on systems like Arch.

File-Level Changes

Change Details Files
Ensure CMake finds the Qt::WaylandClientPrivate target required by the dbus module.
  • Add WaylandClientPrivate to the list of required Qt6 components in the top-level find_package(Qt6 ...) call so CMake defines the Qt::WaylandClientPrivate target.
  • Leave all other CMake configuration, dependencies, and options unchanged to minimize impact.
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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Since WaylandClientPrivate is a private Qt module that may not be present or exported in all Qt builds, consider making this dependency optional (e.g., using find_package(Qt6 COMPONENTS WaylandClientPrivate QUIET) plus a feature toggle) or gating the code that uses it behind a CMake option to avoid hard build failures on platforms without this target.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since `WaylandClientPrivate` is a private Qt module that may not be present or exported in all Qt builds, consider making this dependency optional (e.g., using `find_package(Qt6 COMPONENTS WaylandClientPrivate QUIET)` plus a feature toggle) or gating the code that uses it behind a CMake option to avoid hard build failures on platforms without this target.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Co-authored-by: Gary Wang <git@blumia.net>
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码在 CMake 构建脚本中添加了对 Qt 6.10 及以上版本中 WaylandClientPrivate 组件的条件查找。以下是对该代码的审查意见,涵盖语法逻辑、代码质量、性能和安全性四个方面:

1. 语法逻辑

  • 版本判断逻辑if(Qt6_VERSION VERSION_GREATER_EQUAL 6.10) 的写法在 CMake 中是标准的版本比较语法,逻辑上是正确的。它确保了只有在 Qt 6.10 或更高版本时才会尝试查找私有模块。
  • 依赖声明位置:将条件依赖放在公共依赖 find_package(Qt6 ...) 之后是合理的,因为 Qt6_VERSION 变量只有在执行了 find_package(Qt6 ...) 后才会被定义。

2. 代码质量

  • 私有模块的使用:代码引入了 WaylandClientPrivate。通常情况下,Qt 的私有模块(如 *Private)是不稳定的,其 API 可能在未来的 Qt 版本中发生变化。建议确认是否真的必须使用该私有模块。如果是,请确保代码中有相应的版本宏保护,以便在未来 API 变更时能够快速定位和修复。
  • 缺失版本兼容性处理:代码仅处理了 Qt >= 6.10 的情况。如果项目需要在旧版本(如 6.5, 6.8)上编译,且旧版本不需要该私有模块,目前的写法是可以的。但如果项目在旧版本上编译且旧版本必须通过某种方式(如打补丁或使用旧版私有 API)实现相同功能,则需要补充 else 分支。
  • CMake 版本要求:使用 VERSION_GREATER_EQUAL 是比较现代的 CMake 特性,请确保项目根目录的 cmake_minimum_required(VERSION ...) 版本不低于 3.7(虽然现在大多数项目都已高于此版本)。

3. 代码性能

  • 构建时间find_package 操作通常会有一定的开销,但由于这里使用了 if 条件判断,只有在满足特定版本时才会执行额外的查找。因此,对于不满足条件的构建环境,不会增加额外的构建时间开销,性能处理得当。

4. 代码安全

  • REQUIRED 关键字:在 find_package(Qt6 COMPONENTS WaylandClientPrivate REQUIRED) 中使用了 REQUIRED。这意味着如果系统安装了 Qt 6.10+ 但由于某种原因(如安装不完整)缺少该私有组件,CMake 配置阶段会直接报错并终止。这是安全且符合预期的做法,防止了后续编译因缺少头文件而产生难以理解的错误。
  • 隐式依赖风险:引入 WaylandClientPrivate 可能会引入 Qt 内部未公开的依赖。在打包发布(如制作 deb/rpm 包)时,需要确保生成的依赖关系正确,防止运行时因缺少底层库而崩溃。

改进建议

为了提高代码的健壮性和可维护性,建议对代码进行如下微调:

  1. 添加注释:说明为什么需要 6.10 版本以及引入该私有模块的目的。
  2. 处理非 REQUIRED 场景(可选):如果该私有模块是可选的(即有它功能全,没它功能降级),可以将 REQUIRED 改为检查结果并设置定义宏。

优化后的代码示例:

find_package(Qt6 REQUIRED COMPONENTS Core DBus Concurrent WaylandClient Gui)

# 引入 WaylandClientPrivate 以支持 Qt 6.10+ 的新特性
# 注意:使用私有 API 需谨慎,未来版本可能会变动
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.10)
    find_package(Qt6 COMPONENTS WaylandClientPrivate)
    if(Qt6WaylandClientPrivate_FOUND)
        # 如果找到了,定义一个宏,方便在 C++ 代码中进行条件编译
        add_definitions(-DQT_WAYLANDCLIENT_PRIVATE_SUPPORT)
    else()
        message(WARNING "Qt 6.10+ detected but WaylandClientPrivate module not found. Some features may be disabled.")
    endif()
endif()

find_package(Dtk6 REQUIRED COMPONENTS Core)
find_package Threads REQUIRED)
find_package(TreelandProtocols REQUIRED)

修改点说明:

  • 移除了 REQUIRED,改为检查 Qt6WaylandClientPrivate_FOUND。这使得构建过程更具弹性,除非该功能是核心必须的。
  • 添加了 add_definitions,这样 C++ 代码可以使用 #ifdef QT_WAYLANDCLIENT_PRIVATE_SUPPORT 来安全地包含私有头文件。
  • 添加了 message(WARNING ...),在开发者环境配置不完美时提供明确的提示。

如果该模块是必须的(即没有它程序无法运行),则保持原样即可,但建议添加注释。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: felixonmars, zccrs

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

@zccrs zccrs merged commit ea64013 into linuxdeepin:master Jan 20, 2026
13 of 14 checks passed
@felixonmars felixonmars deleted the patch-1 branch January 20, 2026 06:33
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.

4 participants