对于 CMake 的“安装"命令,COMPONENT 参数可以做什么? [英] For CMake's "install" command, what can the COMPONENT argument do?

查看:23
本文介绍了对于 CMake 的“安装"命令,COMPONENT 参数可以做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道 install() 命令意味着,我不理解 CMake 文档.更详细的是什么?

I don't know what the argument COMPONENT of the install() command means, and I don't understand the CMake documentation for this. What is it in more detail?

一个例子是什么?

推荐答案

您可以将安装目标分组到组件中,例如docs"、libs"、runtime"等

You can group installation targets into components, for example, "docs", "libs", "runtime", etc.

add_library(libone libone.c)
add_executable(one main1.c)
install(TARGETS libone one DESTINATION /somedir COMPONENT comp_one)

add_library(libtwo libtwo.c)
add_executable(two main2.c)
install(TARGETS libtwo two DESTINATION /somedir COMPONENT comp_two)

这使得可以运行 cmake -DCOMPONENT=comp_one -P {your_build_dir}/cmake_install.cmake 来仅安装 libone 库和 one 可执行文件.当您发出 make install 时,所有组件都已安装.

This makes it possible to run cmake -DCOMPONENT=comp_one -P {your_build_dir}/cmake_install.cmake to install only the libone library and the one executable. When you issue make install all components are installed.

这篇关于对于 CMake 的“安装"命令,COMPONENT 参数可以做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆