linux 无root权限 升级cmake版本(源码)
-
下载源码
https://cmake.org/download/
在Source distributions:里面下载 cmake-3.20.0-rc4.tar.gz文件 -
解压
tar -zxvf cmake-3.20.0-rc4.tar.gz
-
cmake安装
$ cd cmake-3.20.0-rc4
$ ./bootstrap --prefix=$HOME/opt/cmake3.12.0 //记得一定要加--prefix,否则会后面会失败
$ make
$ make install
- 更改环境变量
$ vim ~/.bashrc
添加一行
export PATH=$HOME/opt/cmake3.20.0/bin:$PATH
激活环境变量
$ source ~/.bashrc
- 查看cmake版本
进到 $HOME/opt/cmake3.20.0/bin 目录下
cmake --version
成功!
ref:
[1] https://askubuntu.com/questions/1053329/installing-cmakes-latest-version-from-binary-without-using-sudo/1053340#1053340
[2] https://www.cnblogs.com/leeguang/p/10849584.html