cmake
build_error
ai_generated
true
CMake 错误:未设置策略 CMP0068:macOS 上的 RPATH 设置不影响 install_name。
CMake Error: Policy CMP0068 is not set: RPATH settings on macOS do not affect install_name.
ID: cmake/policy-cmp0068-not-set
85%修复率
85%置信度
1证据数
2023-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| CMake 3.9+ | active | — | — | — |
| macOS 10.12+ | active | — | — | — |
| Xcode 9+ | active | — | — | — |
根因分析
未设置 CMake 策略 CMP0068。在 macOS 上,构建系统可能为共享库生成错误的 install_name,导致运行时链接问题。
English
CMake policy CMP0068 is not set. On macOS, the build system may generate incorrect install_name for shared libraries, leading to runtime linking issues.
官方文档
https://cmake.org/cmake/help/latest/policy/CMP0068.html解决方案
-
在任何目标创建之前,在 CMakeLists.txt 中添加 `cmake_policy(SET CMP0068 NEW)` 以采用新行为。
-
或者,如果旧行为更合适,设置策略为 OLD:`cmake_policy(SET CMP0068 OLD)`。
无效尝试
常见但无效的做法:
-
70% 失败
This may break relocation or cause install_name to be hardcoded, not solving the policy mismatch.
-
90% 失败
The error may cause runtime library loading failures on macOS; ignoring it does not fix the root cause.