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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://cmake.org/cmake/help/latest/policy/CMP0068.html

解决方案

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

无效尝试

常见但无效的做法:

  1. 70% 失败

    This may break relocation or cause install_name to be hardcoded, not solving the policy mismatch.

  2. 90% 失败

    The error may cause runtime library loading failures on macOS; ignoring it does not fix the root cause.