Files
tsl-devkit/docs/cpp/dependencies_conan.md
T
csh ac794a6a70 Squashed 'docs/standards/playbook/' changes from e504a68..b529012
b529012  test(tests): avoid hardcoded missing path
07583c8 🐛 fix(tests): make doc link check awk-portable
6244aa3 🔧 chore(ci): relax gitattributes check
31dd0c5 🐛 fix(scripts): require existing project root
15d4d63 🔧 chore(ci): install python3-pip
90c6313 🔧 chore(ci): run tests in a single job
d84eff0 🔧 chore(ci): make actions base url configurable
395598d 🔧 chore(ci): fix yaml step names
4ae2733  feat(sync_standards): auto-detect existing languages
e97fb00  feat(sync_standards): default gitattributes to append
da0ef2b  test: add automated tests and ci workflow
99bef30 🎨 style(markdown): format all markdown files with prettier
7e96bc8 ♻️ refactor(tsl): split function.md into 44 modular files
0d6b2a0 📝 docs(readme): add quick decision table and TL;DR for distribution methods
3b2188f 🎨 style(markdown): format markdown files with prettier
41fc43b 📝 docs(tsl): document {Unit.}Type source annotation
3dceaf7 📝 docs(tsl): clarify tsf-only top-level rules and type annotations
3a63829 📝 docs(skills): add create-plan skill
f02a707 🐛 fix(scripts): escape markdown backticks in vendor_playbook
064aa92 🐛 fix(scripts): correct bat scripts
4881feb 🔧 chore(gitattributes): enforce crlf for bat files
1fa3e2a 🐛 fix(scripts): escape parentheses in sync_standards output
3958cad 📝 docs(vendor_playbook): mention ci templates
9d059cf  feat(templates): add gitea ci example
a52bb24 📝 docs(codex_skills): normalize markdown formatting
cc8ad4c 📝 docs(skills): slim commit-message
2a98e15 🐛 fix(skills): quote YAML descriptions
8f78d22 🐛 fix(sync_standards): generate minimal AGENTS.md
5547665  feat(skills): add commit-message suggestion skill
3fe8bd7 🔧 chore(sync_standards): create AGENTS.md on sync
283d311  feat(playbook): add syntax book and codex skills tooling
5b97ed5 📝 docs(tsl): clarify syntax references
27e0700  feat(skills): add pdf/docx/pptx/xlsx wrapper workflows
5551363  feat(skills): add debugging and bulk refactor workflows
1d4f548  feat(skills): add built-in workflow skills
c0895dd 📝 docs(skills): add anthropics document-skills integration
cf9f80d 🔧 chore(playbook): add Claude Code skills guide and align python templates

git-subtree-dir: docs/standards/playbook
git-subtree-split: b529012c59c5d67c3073884d7b617763647417fd
2026-01-08 15:56:36 +08:00

86 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# C++ 第三方依赖(Conan
本章节给出 Conan + CMake 的推荐落地方式(参考 `tsl-devkit/lsp-server/`
的实践)。
## 1. 基本约定
- 依赖清单使用 `conanfile.txt`(或项目统一的 `conanfile.py`)。
- 本 Playbook 不内置“标准依赖集合/固定版本”;依赖选择与版本锁定由具体项目维护。
- Conan`2.x`(本 Playbook 假设 Conan 2;不保证 Conan 1 的兼容性)
- 生成器使用:
- `CMakeDeps`
- `CMakeToolchain`
- layout 使用:`cmake_layout`(让 build 目录结构稳定可预测)
## 2. 目录与文件(建议)
```txt
cpp/
conanfile.txt
conan/
profiles/
<platform>-<arch>-clang
windows-<arch>-clang-cross
CMakeLists.txt
CMakeUserPresets.json
build/ # 本地/CI 生成,通常不入库
```
## 3. Profile 命名与含义(规范)
- Profile 文件名按“产物平台”为前缀,避免误读:
- `linux-...`:产物平台为 Linux`[settings] os=Linux`
- `windows-...`:产物平台为 Windows`[settings] os=Windows`
- 跨编译 profile 建议以 `-cross` 结尾(例如 `windows-x86_64-clang-cross`)。
- “工具链版本”以 profile 的 `[settings] compiler.version`
为准;如同一仓库并存多版本 clang,可将版本体现在文件名中(例如
`linux-x86_64-clang20`)。
## 4. 安装与构建(推荐流程)
在项目的 C++ 根目录(例如 `cpp/`)下:
1. 安装依赖并生成工具链文件:
- `CONAN_HOME=/tmp/conan-home conan install . -pr:b=conan/profiles/linux-x86_64-clang -pr:h=conan/profiles/windows-x86_64-clang-cross -of build/windows-x86_64-clang-cross --build=missing`
- 若有 profile`-pr:h=conan/profiles/<...> -pr:b=conan/profiles/<...>`
2. 配置 CMake
- 直接指定 toolchain
- `cmake -S . -B build/clang -G Ninja -DCMAKE_TOOLCHAIN_FILE=$PWD/build/clang/Release/generators/conan_toolchain.cmake`
- 或使用 Presets(推荐,见下节):
- `cmake --preset conan-release`
3. 构建:
- `cmake --build --preset conan-release -j 8`
提示:如遇到 Conan 缓存/家目录权限问题,可临时设置 `CONAN_HOME=/tmp/conan-home`
再执行。
## 5. CMake Presets(推荐做法)
Conan 2 可以生成 CMake Presets(通常落在
`build/<...>/generators/CMakePresets.json`)。
推荐将一个稳定的 `CMakeUserPresets.json` 放进仓库并 include 生成文件(参考
`tsl-devkit/lsp-server/CMakeUserPresets.json`),例如:
```json
{
"version": 4,
"vendor": { "conan": {} },
"include": ["build/clang-linux/Release/generators/CMakePresets.json"]
}
```
这样团队/CI 就可以统一使用:
- 配置:`cmake --preset conan-release`
- 构建:`cmake --build --preset conan-release -j 8`
- 测试:`ctest --preset conan-release --output-on-failure`
## 6. 模板文件(本 Playbook
- `templates/cpp/conanfile.txt`
- `templates/cpp/CMakeUserPresets.json`
- `templates/cpp/conan/profiles/linux-x86_64-clang`
- `templates/cpp/conan/profiles/windows-x86_64-clang-cross`