如何指定CMake在Ubuntu中的安装位置? [英] How to specify where CMake is installed in Ubuntu?
问题描述
我已经下载了 cmake-3.11.3-Linux-x86_64.sh
文件。然后我执行了它,它创建了一个文件夹,该文件夹上有一个 bin
文件,上面有 cmake
。我试图像这样编辑 / etc / environment
:
I have downloaded the cmake-3.11.3-Linux-x86_64.sh
file. Then I executed it and it created a folder that has a bin
file there is cmake
on it. I tried to edit /etc/environment
like this:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/m/FILES/CMake/cmake-3.11.3-Linux-x86_64/bin"
但是当我尝试此命令时:
But when I try this command:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
我收到此消息:
程序'cmake目前尚未安装。您可以通过键入
来安装它:sudo apt install cmake
The program 'cmake' is currently not installed. You can install it by typing: sudo apt install cmake
我所做的哪一部分是错误的,以及如何我解决了吗?
Which part of what I did, is wrong and how can I fix that?
推荐答案
我假设您从 CMake的下载页面。毫无疑问,如何使用它的文档很少。
I assume you downloaded the script from CMake's Download Page. The documentation how to use it is admittedly a little sparse.
简而言之,调用(CMake的安装路径为 / usr / local
):
In short, call (installation path for CMake here is /usr/local
):
# sudo cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
注意:您需要先卸载所有安装了CMake软件包的软件包管理器
Note: You need to uninstall any package manager installed CMake packages first
# sudo apt remove cmake
# sudo apt purge --auto-remove cmake
选项
该脚本具有以下选项:
# cmake-3.11.3-Linux-x86_64.sh --help
Usage: cmake-3.11.3-Linux-x86_64.sh [options]
Options: [defaults in brackets after descriptions]
--help print this message
--version print cmake installer version
--prefix=dir directory in which to install
--include-subdir include the cmake-3.11.3-Linux-x86_64 subdirectory
--exclude-subdir exclude the cmake-3.11.3-Linux-x86_64 subdirectory
--skip-license accept license
您要搜索的是-prefix = dir
。否则,它将仅使用当前目录提取安装文件。
The one you are searching for is --prefix=dir
. Otherwise it will just use the current directory to extract the installation files.
在Ubuntu上测试输出
# cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
CMake Installer Version: 3.11.3, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /usr/local
Using target directory: /usr/local
Extracting, please wait...
Unpacking finished successfully
# cmake --version
cmake version 3.11.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
参考/替代
- Ask Ubuntu: How do I install the latest version of cmake from the command line?
这篇关于如何指定CMake在Ubuntu中的安装位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!