在CMAKE中安装目标时,如何导出目标属性
我有以下示例项目,我想导出stolopts_list
属性。
cmake_minimum_required(VERSION 3.14.0)
project(exported_props LANGUAGES CXX)
add_library(protocols ...)
set_target_properties(protocols PROPERTIES PROTOCOLS_LIST "IP" "TCP" "UDP")
install(TARGETS protocols EXPORT protocol)
install(EXPORT protocol DESTINATION ${CMAKE_BINARY_DIR})
安装上面的示例代码时,创建的stolopt.cmake
文件将不包含我的自定义属性protasts_list
。
安装目标时是否可以通过某些目标的属性?
I have the following sample project which I would like to export PROTOCOLS_LIST
properties.
cmake_minimum_required(VERSION 3.14.0)
project(exported_props LANGUAGES CXX)
add_library(protocols ...)
set_target_properties(protocols PROPERTIES PROTOCOLS_LIST "IP" "TCP" "UDP")
install(TARGETS protocols EXPORT protocol)
install(EXPORT protocol DESTINATION ${CMAKE_BINARY_DIR})
When installing the above sample code, the created protocol.cmake
file will not contain my custom property PROTOCOLS_LIST
.
Is it possible to pass some target's properties when installing TARGETS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,CMAKE仅安装特定的目标属性集。
要告诉CMAKE要安装其他属性,您可以列出目标的属性:
By default, CMake installs only specific set of target's properties.
For tell CMake to install additional properties you could list that properties in the EXPORT_PROPERTIES target's property: