什么是CMake等同于'configure --prefix = DIR&&全部安装'? [英] What is CMake equivalent of 'configure --prefix=DIR && make all install '?

查看:102
本文介绍了什么是CMake等同于'configure --prefix = DIR&&全部安装'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做 cmake。 &&完成所有安装。可以,但是安装到 / usr / local

I do cmake . && make all install. This works, but installs to /usr/local.

我需要安装到其他前缀(例如,以 / usr )。

I need to install to a different prefix (for example, to /usr).

什么是 cmake make 命令行安装到 / usr 而不是 / usr / local

What is the cmake and make command line to install to /usr instead of /usr/local?

推荐答案

从CMake 3.15开始,您可以运行-install 版本:

As of CMake 3.15 you can run the --install version of CMake after building:

$ cmake --install /path/to/build --prefix /path/to/install [--config <CONFIG>]

包括 --config (如果您使用的是像Visual Studio这样的多配置生成器。

Include --config if you're using a multi-config generator like Visual Studio.

在以前的版本中,您可以执行 cmake_install.cmake 脚本:

In prior versions, you could execute the cmake_install.cmake script:

$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/path/to/install -P cmake_install.cmake 



< hr>

最后,您可以在co处指定安装前缀nfigure-time,然后按如下步骤进行构建和安装:


Finally, you can specify the install prefix at configure-time, and then build and install in one step as follows:

$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/path/to/install /path/to/src
$ cmake --build . --target install

您可以添加 --config Release 到第三条命令,或者 -DCMAKE_BUILD_TYPE = Release 到第二条命令,这取决于分别使用的是多配置生成器还是单配置生成器

You would either add --config Release to the third command or -DCMAKE_BUILD_TYPE=Release to the second command, depending on whether you were using a multi-config generator or a single-config generator, respectively.

(路径)类型不是严格必需的,但是会导致基于Qt的cmake-gui显示目录选择器对话框。

The type (PATH) is not strictly necessary, but causes the Qt based cmake-gui to present the directory chooser dialog.

这篇关于什么是CMake等同于'configure --prefix = DIR&amp;&amp;全部安装'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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