在CMAKE中安装目标时,如何导出目标属性

发布于 2025-02-06 15:16:27 字数 477 浏览 0 评论 0原文

我有以下示例项目,我想导出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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赴月观长安 2025-02-13 15:16:27

默认情况下,CMAKE仅安装特定的目标属性集。

要告诉CMAKE要安装其他属性,您可以列出目标的属性:

# Tell CMake to install PROTOCOLS_LIST property for the target.
set_property(TARGET protocols APPEND PROPERTY EXPORT_PROPERTIES PROTOCOLS_LIST)

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:

# Tell CMake to install PROTOCOLS_LIST property for the target.
set_property(TARGET protocols APPEND PROPERTY EXPORT_PROPERTIES PROTOCOLS_LIST)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文