# CMake 错误：FetchContent：完整性检查失败 <https://example.com/repo/archive/v1.0.tar.gz>
  期望哈希：abc123def456
  实际哈希：789012ghi345

- **ID:** `cmake/fetchcontent-integrity-failure`
- **领域:** cmake
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

下载的存档哈希与 FetchContent_Declare 中指定的期望哈希不匹配，表明下载损坏、中间人攻击或期望哈希已过时。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| cmake 3.14 | active | — | — |
| cmake 3.20 | active | — | — |
| cmake 3.28 | active | — | — |

## 解决方案

1. ```
   删除缓存的下载：rm -rf build/_deps/<name>-src 然后重新配置以强制重新下载。
   ```
2. ```
   将 FetchContent_Declare 中的期望哈希更新为官方来源的正确哈希，然后清除缓存。
   ```

## 无效尝试

- **** — FetchContent caches the corrupted archive; need to delete the _deps directory first. (60% 失败率)
- **** — May accept a malicious or corrupted file; always verify the hash from a trusted source. (80% 失败率)
