Skip to content

Commit ce0338f

Browse files
IronsDuclaude
andauthored
docs: improve build/install sections and add CMake options documentation (#39)
* docs: improve build/install sections and add CMake options documentation - README: add CMake options table, build type explanations, common build scenarios, and install instructions with file layout - 05_installation.md: rewrite to remove fictional content (Conan, system package managers) and keep only actually available methods (source build, FetchContent, add_subdirectory) with correct examples from cmake/examples/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: update docs/README.md to match rewritten installation guide - Update installation guide description to reflect actual methods - Fix GitHub repo URL from placeholder to actual IronsDu/cpp-remote-profiler Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3f0ee31 commit ce0338f

3 files changed

Lines changed: 305 additions & 430 deletions

File tree

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- [功能特性](#-功能特性)
99
- [设计理念](#-设计理念)
1010
- [快速开始](#-快速开始)
11+
- [CMake 构建选项](#-cmake-构建选项)
12+
- [安装](#-安装)
1113
- [使用方法](#-使用方法)
1214
- [如何查看火焰图](#-如何查看火焰图)
1315
- [API 端点](#-api-端点)
@@ -171,6 +173,115 @@ cmake .. \
171173
make -j$(nproc)
172174
```
173175

176+
**构建类型说明**`CMAKE_BUILD_TYPE`):
177+
178+
| 构建类型 | 说明 |
179+
|---------|------|
180+
| `Release` | 优化编译(`-O2`),适合生产使用 |
181+
| `Debug` | 无优化(`-O0`),适合调试 |
182+
| `RelWithDebInfo` | 优化编译且包含调试符号(**默认**),推荐用于 profiling |
183+
184+
> 所有构建类型默认包含 `-g` 调试符号,以确保 profiling 结果能正确显示函数名。
185+
186+
## ⚙️ CMake 构建选项
187+
188+
项目提供以下 CMake 选项,可通过 `-D<Option>=<Value>` 在配置时指定。
189+
190+
### 选项列表
191+
192+
| 选项 | 默认值 | 说明 |
193+
|------|--------|------|
194+
| `BUILD_SHARED_LIBS` | `ON` | 构建动态库(`.so`),设为 `OFF` 则构建静态库(`.a`|
195+
| `REMOTE_PROFILER_INSTALL` | `ON` | 生成 install target,设为 `OFF` 则不生成安装规则 |
196+
| `REMOTE_PROFILER_BUILD_EXAMPLES` | `ON` | 构建示例程序(`profiler_example`|
197+
| `REMOTE_PROFILER_BUILD_TESTS` | `ON` | 构建测试程序 |
198+
| `REMOTE_PROFILER_ENABLE_WEB` | `ON` | 启用 Web UI(依赖 Drogon),设为 `OFF` 则无需 Drogon |
199+
| `ENABLE_COVERAGE` | `OFF` | 启用代码覆盖率报告(需要 GCC 或 Clang) |
200+
| `BUILD_DOCS` | `OFF` | 构建 API 文档(需要 Doxygen) |
201+
202+
### 常见构建场景
203+
204+
**完整构建**(默认,含 Web UI 和所有组件):
205+
206+
```bash
207+
cmake .. \
208+
-DCMAKE_BUILD_TYPE=Release \
209+
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
210+
-DVCPKG_TARGET_TRIPLET=x64-linux-release
211+
```
212+
213+
**最小化构建**(仅核心 profiling 库,不需要 Drogon):
214+
215+
```bash
216+
cmake .. \
217+
-DCMAKE_BUILD_TYPE=Release \
218+
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
219+
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
220+
-DREMOTE_PROFILER_ENABLE_WEB=OFF \
221+
-DREMOTE_PROFILER_BUILD_EXAMPLES=OFF \
222+
-DREMOTE_PROFILER_BUILD_TESTS=OFF
223+
```
224+
225+
**仅构建核心库(用于集成到其他项目)**
226+
227+
```bash
228+
cmake .. \
229+
-DCMAKE_BUILD_TYPE=Release \
230+
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
231+
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
232+
-DREMOTE_PROFILER_ENABLE_WEB=OFF \
233+
-DREMOTE_PROFILER_BUILD_EXAMPLES=OFF \
234+
-DREMOTE_PROFILER_BUILD_TESTS=OFF \
235+
-DBUILD_SHARED_LIBS=OFF
236+
```
237+
238+
> 构建静态库(`BUILD_SHARED_LIBS=OFF`)后可使用 `cmake --install` 安装,其他项目通过 `find_package` 集成。详见 [集成到你的项目](#-集成到你的项目)
239+
240+
**构建带 API 文档的版本**
241+
242+
```bash
243+
cmake .. \
244+
-DCMAKE_BUILD_TYPE=Release \
245+
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
246+
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
247+
-DBUILD_DOCS=ON
248+
```
249+
250+
文档生成后位于 `build/docs/html/` 目录。
251+
252+
## 📦 安装
253+
254+
```bash
255+
# 安装到默认路径(通常为 /usr/local)
256+
cmake --install build
257+
258+
# 安装到指定路径
259+
cmake --install build --prefix /opt/cpp-remote-profiler
260+
```
261+
262+
安装后的文件布局:
263+
264+
```
265+
<prefix>/
266+
├── include/cpp-remote-profiler/ # 头文件
267+
│ ├── profiler_manager.h
268+
│ ├── profiler_version.h
269+
│ ├── version.h
270+
│ └── profiler/
271+
│ ├── http_handlers.h
272+
│ └── log_sink.h
273+
├── lib/
274+
│ ├── libprofiler_core.so # 核心库
275+
│ ├── libprofiler_web.so # Web 库(如果启用)
276+
│ └── cmake/cpp-remote-profiler/ # CMake 配置文件
277+
│ ├── cpp-remote-profiler-config.cmake
278+
│ ├── cpp-remote-profiler-config-version.cmake
279+
│ └── cpp-remote-profiler-targets.cmake
280+
└── share/doc/cpp-remote-profiler/ # 文档(如果启用 BUILD_DOCS)
281+
```
282+
283+
> 安装后,其他项目可通过 `find_package(cpp-remote-profiler)` 直接使用。详见 [集成到你的项目](#-集成到你的项目)
284+
174285
### 5. 运行服务
175286

176287
```bash

docs/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
- 编译和运行
1414
- 下一步指引
1515

16-
2. **[安装指南](user_guide/05_installation.md)** ⭐ 新增
17-
- 方法 1: 使用 vcpkg(推荐)
18-
- 方法 2: 使用 Conan
19-
- 方法 3: 使用 FetchContent
20-
- 方法 4: 手动编译
21-
- 方法 5: 系统包管理器
16+
2. **[安装指南](user_guide/05_installation.md)**
17+
- 方法 1: 从源码编译安装
18+
- 方法 2: FetchContent 集成
19+
- 方法 3: add_subdirectory 集成
20+
- CMake 构建选项说明
2221
- 验证安装和故障排除
2322

2423
3. **[使用 find_package](user_guide/06_using_find_package.md)** ⭐ 新增
@@ -84,7 +83,7 @@
8483
- **主 README**: [项目根目录 README](../README.md)
8584
- **项目规划**: [plan.md](../plan.md)
8685
- **开发规则**: [notes.md](../notes.md)
87-
- **GitHub 仓库**: [https://github.com/your-org/cpp-remote-profiler](https://github.com/your-org/cpp-remote-profiler)
86+
- **GitHub 仓库**: [https://github.com/IronsDu/cpp-remote-profiler](https://github.com/IronsDu/cpp-remote-profiler)
8887

8988
## 🔗 外部参考
9089

0 commit comments

Comments
 (0)