cmake官网:https://cmake.org/download/
1.解压源码
tar -zxvf cmake-3.27.9-linux-x86_64.tar.gz
2.移动解压的文件夹到/opt下
sudo mv cmake-3.27.9-linux-x86_64 /opt/
3.编辑~/.bashrc, 把cmake路径添加到环境变量中
export PATH=/opt/cmake-3.27.9-linux-x86_64/bin:$PATH
4.保存后关闭文件,并命令行输入
source ~/.bashrc
5.环境变量生效后,查看cmake --version
cmake --version