38 lines
1.2 KiB
Markdown
38 lines
1.2 KiB
Markdown
---
|
|
id: VDE-002
|
|
status: open
|
|
severity: high
|
|
category: build
|
|
date: 2026-07-27
|
|
reporter: ViewDesign
|
|
---
|
|
|
|
# VDE-002: 子模块模式下 include 路径无法解析
|
|
|
|
## 问题描述
|
|
|
|
ViewDesignEngine 的 CMakeLists.txt 使用 ${CMAKE_SOURCE_DIR}/include 作为公共头文件搜索路径。独立构建时,CMAKE_SOURCE_DIR 指向 ViewDesignEngine 仓库根目录。但作为子模块被 ViewDesign 引入时,CMAKE_SOURCE_DIR 指向 ViewDesign 根目录,而 ViewDesign 没有 include/vde/ 目录,导致头文件找不到。
|
|
|
|
## 影响文件
|
|
|
|
- src/CMakeLists.txt
|
|
- 所有使用 ${CMAKE_SOURCE_DIR}/include 的目标
|
|
|
|
## ViewDesign 侧 Workaround
|
|
|
|
在父工程 CMakeLists.txt 中手动添加 VDE 真实 include 路径:
|
|
|
|
```cmake
|
|
target_include_directories(vde_foundation PUBLIC "${CMAKE_SOURCE_DIR}/third_party/ViewDesignEngine/include")
|
|
```
|
|
|
|
## 建议修复方向
|
|
|
|
1. 使用 ${CMAKE_CURRENT_SOURCE_DIR}/../include 代替 ${CMAKE_SOURCE_DIR}/include
|
|
2. 使用 generator expression: $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
|
3. 支持作为子目录被 add_subdirectory 引入
|
|
4. 考虑提供 CMake package config 文件
|
|
|
|
---
|
|
*此文件由 ViewDesign 工程自动生成。处理完成后请更新 status 字段。*
|