# CMake警告（开发）：未设置策略CMP0077：option()尊重普通变量。运行"cmake --help-policy CMP0077"查看策略详情。使用cmake_policy命令设置策略并抑制此警告。

- **ID:** `cmake/policy-cmp0077-not-set`
- **领域:** cmake
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

未显式设置CMake策略CMP0077，导致当存在同名普通变量时，option()行为不一致。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| CMake 3.13 | active | — | — |
| CMake 3.14 | active | — | — |
| CMake 3.20 | active | — | — |

## 解决方案

1. ```
   在CMakeLists.txt开头设置策略为NEW：cmake_policy(SET CMP0077 NEW)
   ```
2. ```
   如果需要旧行为，设置为OLD：cmake_policy(SET CMP0077 OLD)，但不推荐用于新项目。
   ```

## 无效尝试

- **** — The warning may lead to subtle bugs where option() does not behave as expected, especially in cache variable scenarios. (40% 失败率)
- **** — OLD behavior may break modern CMake patterns and cause unexpected cache variable behavior. (50% 失败率)
