# CMake 错误：未设置策略 CMP0068：macOS 上的 RPATH 设置不影响 install_name。

- **ID:** `cmake/policy-cmp0068-not-set`
- **领域:** cmake
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

未设置 CMake 策略 CMP0068。在 macOS 上，构建系统可能为共享库生成错误的 install_name，导致运行时链接问题。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| CMake 3.9+ | active | — | — |
| macOS 10.12+ | active | — | — |
| Xcode 9+ | active | — | — |

## 解决方案

1. ```
   在任何目标创建之前，在 CMakeLists.txt 中添加 `cmake_policy(SET CMP0068 NEW)` 以采用新行为。
   ```
2. ```
   或者，如果旧行为更合适，设置策略为 OLD：`cmake_policy(SET CMP0068 OLD)`。
   ```

## 无效尝试

- **** — This may break relocation or cause install_name to be hardcoded, not solving the policy mismatch. (70% 失败率)
- **** — The error may cause runtime library loading failures on macOS; ignoring it does not fix the root cause. (90% 失败率)
