什么是cmake_install.cmake [英] What is cmake_install.cmake

查看:1911
本文介绍了什么是cmake_install.cmake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个非常简单的HelloWorld.c程序,并运行了Cmake。它在我的构建目录中创建了一个 cmake_install.cmake 文件。有人可以向我解释为什么CMake生成文件cmake_install.cmake吗?

I wrote a very simple HelloWorld.c program and ran Cmake. It created a cmake_install.cmake file in my build directory. Can somebody explain to me why CMake generated the file cmake_install.cmake? What is it's purpose and how can I use it?

CMakelists.txt:

CMakelists.txt :

cmake_minimum_required(VERSION 3.0)
PROJECT(FirstExample)
add_executable(prog first.c) 

谢谢!

推荐答案

通常,您通常不直接使用cmake_install.cmake。在 v3.12页面中指出:

You generally don't use cmake_install.cmake directly. From the v3.12 page it states:


install()命令在
构建目录中生成一个文件cmake_install.cmake,该文件在生成的install
目标内部使用并通过 CPack

使用您当前的CMakeLists.txt,生成的文件不会做很多事情。要创建有用的安装,您需要使用以下语法向 CMakeLists.txt 中添加更多 INSTALL 命令。

With your current CMakeLists.txt, the generated file doesn't do much. To create a useful install you would need to add more INSTALL commands to your CMakeLists.txt using the syntax below.

INSTALL(TARGETS targets... [EXPORT <export-name>]
    [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|
      PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]
     [DESTINATION <dir>]
     [INCLUDES DESTINATION [<dir> ...]]
     [PERMISSIONS permissions...]
     [CONFIGURATIONS [Debug|Release|...]]
     [COMPONENT <component>]
     [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
    ] [...])

有关此命令的更多信息,请查看文档站点维基

For further reading on this command, check out the documentation site and wiki.

如果需要手动执行如Nic30g所述,脚本在3.12页中指出 cmake -P 接受以下变量:

If it's desired to manually execute the script as stated by Nic30g the 3.12 page states that cmake -P accepts the following variables:

COMPONENT

将此变量设置为仅安装一个 CPack 组件,而不是所有组件。例如,如果您只想安装开发组件,请运行

COMPONENT
Set this variable to install only a single CPack component as opposed to all of them. For example, if you only want to install the Development component, run

 cmake -DCOMPONENT=Development -P cmake_install.cmake

BUILD_TYPE

如果使用多配置,请设置此变量以更改构建类型发电机。例如,要使用Debug配置安装,请运行

BUILD_TYPE
Set this variable to change the build type if you are using a multi-config generator. For example, to install with the Debug configuration, run

 cmake -DBUILD_TYPE=Debug -P cmake_install.cmake.

DESTDIR

这是一个环境变量,而不是CMake变量。它允许您更改UNIX系统上的安装前缀。有关详细信息,请参见 DESTDIR

这篇关于什么是cmake_install.cmake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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