什么是 CMake 等效于 'configure

编程入门 行业动态 更新时间:2024-10-25 10:22:37
本文介绍了什么是 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).

要安装到 /usr 而不是 /usr/localcmakemake 命令行是什么?

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

推荐答案

您可以在命令行中传入任何 CMake 变量,或使用 ccmake/cmake-gui 编辑缓存的变量.在命令行中,

You can pass in any CMake variable on the command line, or edit cached variables using ccmake/cmake-gui. On the command line,

cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr . && make all install

将配置项目,构建所有目标并安装到/usr 前缀.类型 (PATH) 不是绝对必要的,但会导致基于 Qt 的 cmake-gui 显示目录选择器对话框.

Would configure the project, build all targets and install to the /usr prefix. The type (PATH) is not strictly necessary, but would cause the Qt based cmake-gui to present the directory chooser dialog.

作为评论的一些小补充清楚地表明,对某些人来说,提供简单的等效是不够的.最佳实践是使用外部构建目录,即不直接使用源代码.还要使用更通用的 CMake 语法来抽象生成器.

mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && cmake --build . --target install --config Release

您可以看到它变得更长了,并且不再直接等效,而是以相当简洁的形式更接近最佳实践...... --config 仅用于多配置生成器(即 MSVC),被其他人忽略.

You can see it gets quite a bit longer, and isn't directly equivalent anymore, but is closer to best practices in a fairly concise form... The --config is only used by multi-configuration generators (i.e. MSVC), ignored by others.

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

更多推荐

[db:关键词]

本文发布于:2023-03-31 05:06:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/796020.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CMake   configure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!