cmake
install_error
ai_generated
true
CMake 错误:install TARGETS 未指定 DESTINATION,也未指定 RUNTIME、ARCHIVE、LIBRARY 或 BUNDLE 组件。
CMake Error: install TARGETS given no DESTINATION and no RUNTIME, ARCHIVE, LIBRARY, or BUNDLE component.
ID: cmake/install-target-destination-not-set
93%修复率
90%置信度
1证据数
2023-09-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| CMake 3.10 | active | — | — | — |
| CMake 3.16 | active | — | — | — |
| CMake 3.25 | active | — | — | — |
根因分析
install(TARGETS) 命令必须为每种目标类型指定目标路径或组件;否则 CMake 不知道将安装文件放在哪里。
English
The install(TARGETS) command must specify a destination or component for each target type; otherwise, CMake does not know where to place the installed files.
官方文档
https://cmake.org/cmake/help/latest/command/install.html#install-targets解决方案
-
为每种目标类型添加 DESTINATION:install(TARGETS mylib RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static)。示例:install(TARGETS myapp RUNTIME DESTINATION bin)。
-
为所有组件使用单一 DESTINATION:install(TARGETS mylib DESTINATION lib)。这适用于不分离运行时/存档的简单库。
无效尝试
常见但无效的做法:
-
80% 失败
If a target produces both a runtime and a library, both must have destinations; specifying only one leaves the other undefined.
-
95% 失败
CMAKE_INSTALL_PREFIX sets the root, but install(TARGETS) needs explicit DESTINATION relative to that root.