cmake
build_error
ai_generated
true
CMake Error: Policy CMP0068 is not set: RPATH settings on macOS do not affect install_name.
ID: cmake/policy-cmp0068-not-set
85%Fix Rate
85%Confidence
1Evidence
2023-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| CMake 3.9+ | active | — | — | — |
| macOS 10.12+ | active | — | — | — |
| Xcode 9+ | active | — | — | — |
Root Cause
CMake policy CMP0068 is not set. On macOS, the build system may generate incorrect install_name for shared libraries, leading to runtime linking issues.
generic中文
未设置 CMake 策略 CMP0068。在 macOS 上,构建系统可能为共享库生成错误的 install_name,导致运行时链接问题。
Official Documentation
https://cmake.org/cmake/help/latest/policy/CMP0068.htmlWorkarounds
-
85% success Add `cmake_policy(SET CMP0068 NEW)` before any target creation in CMakeLists.txt to adopt new behavior.
Add `cmake_policy(SET CMP0068 NEW)` before any target creation in CMakeLists.txt to adopt new behavior.
-
80% success Alternatively, set policy to OLD: `cmake_policy(SET CMP0068 OLD)` to use legacy behavior if needed.
Alternatively, set policy to OLD: `cmake_policy(SET CMP0068 OLD)` to use legacy behavior if needed.
中文步骤
在任何目标创建之前,在 CMakeLists.txt 中添加 `cmake_policy(SET CMP0068 NEW)` 以采用新行为。
或者,如果旧行为更合适,设置策略为 OLD:`cmake_policy(SET CMP0068 OLD)`。
Dead Ends
Common approaches that don't work:
-
70% fail
This may break relocation or cause install_name to be hardcoded, not solving the policy mismatch.
-
90% fail
The error may cause runtime library loading failures on macOS; ignoring it does not fix the root cause.