Skip to content

fix: correct include path in pkg-config file#727

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Feb 5, 2026
Merged

fix: correct include path in pkg-config file#727
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

The pkg-config file was incorrectly specifying the include path as
${includedir}/dtk@DTK_VERSION_MAJOR@/DWidget. This path was too specific
and did not match the actual header file installation structure. The
change updates the Cflags to use the base ${includedir} directory,
allowing the compiler to find the DtkWidget headers in their correct
location.

This fix ensures that projects using pkg-config to locate DtkWidget
headers will find them properly without requiring manual include path
adjustments. The incorrect path was causing compilation failures in
dependent projects.

Influence:

  1. Test compilation of projects that depend on DtkWidget using pkg-
    config
  2. Verify that include directives like #include work correctly
  3. Check that both cmake and qmake projects can find DtkWidget headers
  4. Test with different DTK versions to ensure version compatibility
  5. Verify that existing projects don't break due to include path changes

fix: 修正 pkg-config 文件中的头文件包含路径

pkg-config 文件之前错误地将包含路径指定为 ${includedir}/
dtk@DTK_VERSION_MAJOR@/DWidget。这个路径过于具体,与实际的头文件安装结构
不匹配。此次更改将 Cflags 更新为使用基础的 ${includedir} 目录,使编译器
能够在正确的位置找到 DtkWidget 头文件。

此修复确保使用 pkg-config 定位 DtkWidget 头文件的项目能够正确找到它们,
而无需手动调整包含路径。之前的错误路径导致依赖项目编译失败。

Influence:

  1. 测试使用 pkg-config 依赖 DtkWidget 的项目的编译
  2. 验证 #include 等包含指令能正常工作
  3. 检查 cmake 和 qmake 项目都能正确找到 DtkWidget 头文件
  4. 使用不同 DTK 版本测试以确保版本兼容性
  5. 验证现有项目不会因包含路径更改而出现问题

The pkg-config file was incorrectly specifying the include path as
${includedir}/dtk@DTK_VERSION_MAJOR@/DWidget. This path was too specific
and did not match the actual header file installation structure. The
change updates the Cflags to use the base ${includedir} directory,
allowing the compiler to find the DtkWidget headers in their correct
location.

This fix ensures that projects using pkg-config to locate DtkWidget
headers will find them properly without requiring manual include path
adjustments. The incorrect path was causing compilation failures in
dependent projects.

Influence:
1. Test compilation of projects that depend on DtkWidget using pkg-
config
2. Verify that include directives like #include <DWidget> work correctly
3. Check that both cmake and qmake projects can find DtkWidget headers
4. Test with different DTK versions to ensure version compatibility
5. Verify that existing projects don't break due to include path changes

fix: 修正 pkg-config 文件中的头文件包含路径

pkg-config 文件之前错误地将包含路径指定为 ${includedir}/
dtk@DTK_VERSION_MAJOR@/DWidget。这个路径过于具体,与实际的头文件安装结构
不匹配。此次更改将 Cflags 更新为使用基础的 ${includedir} 目录,使编译器
能够在正确的位置找到 DtkWidget 头文件。

此修复确保使用 pkg-config 定位 DtkWidget 头文件的项目能够正确找到它们,
而无需手动调整包含路径。之前的错误路径导致依赖项目编译失败。

Influence:
1. 测试使用 pkg-config 依赖 DtkWidget 的项目的编译
2. 验证 #include <DWidget> 等包含指令能正常工作
3. 检查 cmake 和 qmake 项目都能正确找到 DtkWidget 头文件
4. 使用不同 DTK 版本测试以确保版本兼容性
5. 验证现有项目不会因包含路径更改而出现问题
@18202781743 18202781743 requested review from BLumia and mhduiy February 5, 2026 08:35
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

这段代码修改涉及的是 pkg-config 配置文件(DtkWidget.pc.in)的变更。主要修改了 Cflags 字段,将原本包含特定版本号的路径简化为 ${includedir}

以下是对该修改的详细审查意见:

1. 语法逻辑

  • 现状:修改前的 Cflags-I${includedir}/dtk@DTK_VERSION_MAJOR@/DWidget,修改后为 -I${includedir}
  • 分析:语法上两者都是合法的 pkg-config 变量引用。逻辑上,修改后的路径更加通用,意味着编译器将在 ${includedir}(通常是 /usr/include)目录下搜索头文件,而不是限定在特定的子目录中。
  • 潜在风险:这个修改强烈依赖于文件系统中头文件的实际安装布局。
    • 如果头文件安装结构是:/usr/include/dtk6/DWidget/...,那么修改后的 -I${includedir} 将导致编译器找不到头文件,除非用户在编译代码时显式写 #include <dtk6/DWidget/...>,或者该路径被其他机制(如编译器的系统路径)覆盖。
    • 如果头文件安装结构被调整为:/usr/include/DWidget/...(即去掉了版本号中间层),那么这个修改是合理的。

改进建议:请确保该 .pc.in 文件的修改与 CMakeLists.txt(或构建脚本)中的 install(TARGETS ...)install(FILES ...) 路径配置保持一致。如果头文件仍然安装在包含版本号的子目录中,此修改将导致下游依赖该库的项目编译失败

2. 代码质量

  • 兼容性
    • 修改前:显式指定了头文件路径,对文件系统布局的依赖较小,但路径较长且包含版本宏。
    • 修改后:路径更短,更符合现代 Linux 发行版(如 Debian/Ubuntu)对库头文件安装的习惯(通常倾向于扁平化结构或通过 dtk-config 等工具管理),但降低了向后兼容性。
  • 一致性:检查 dtkcoredtkgui.pc 文件是否也进行了类似的修改。如果它们仍然保留了版本号路径,而 dtkwidget 去掉了,这会导致 API 使用上的不一致。

改进建议:统一整个 DTK 生态中各个模块(Core, Gui, Widget)的 .pc 文件 Cflags 配置,确保开发者在使用不同模块时,包含头文件的方式是一致的(例如都使用 #include <DWidget/...> 或都使用 #include <dtk6/DWidget/...>)。

3. 代码性能

  • 分析pkg-config 的解析性能差异可以忽略不计。
  • 编译性能:使用 -I${includedir} 会将根目录加入搜索路径。如果 /usr/include 下文件非常多,理论上可能会对预处理器的头文件搜索速度产生极微小的影响,但在现代硬件上这通常不是瓶颈。

4. 代码安全

  • 安全性:此修改本身不涉及内存安全、权限控制等安全问题。
  • 污染风险:将根目录加入包含路径可能会增加头文件名冲突的风险。例如,如果系统中安装了另一个库也定义了名为 DWidget 的头文件(虽然概率较低),可能会导致错误的包含。之前的限定路径 -I.../DWidget 在一定程度上隔离了这种风险。

总结与建议

这是一个影响 ABI(应用二进制接口)兼容性和构建系统的重大变更。

  1. 确认安装路径:必须确认构建系统(CMake)是否将头文件安装到了 ${includedir} 根目录下,而不是 ${includedir}/dtk@DTK_VERSION_MAJOR@/DWidget。如果安装路径没变,请回退此修改
  2. 更新下游代码:如果头文件确实安装到了根目录,需要检查并更新 DtkWidget 自身的示例代码以及所有依赖 DtkWidget 的下游应用程序的 #include 语句。
    • 旧写法:#include <DWidget>
    • 新写法可能需要调整为:#include <DWidget> (假设文件直接在include下) 或者保持不变(取决于具体的目录结构调整)。
  3. 文档更新:需更新开发文档,说明新的头文件包含方式。

结论:如果这是为了适配新的头文件安装策略(去除了版本号目录层级),则修改是合理的;否则,这是一个破坏性的错误修改。

@18202781743
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Feb 5, 2026

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit c2d2dd1 into linuxdeepin:master Feb 5, 2026
19 of 22 checks passed
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