## 1. 查看当前cmake版本
[root@localhost ~]# cmake -version
cmake version 2.8.12.2
## 2. 进行卸载
[root@localhost ~]# yum remove -y cmake
## 3. 进行安装包的下载,也可以下载好安装包后传至相应的目录
[root@localhost ~]# mkdir /opt/cmake
[root@localhost ~]# cd /opt/cmake/
## 4. 下载或拷贝,解压
[root@localhost cmake]# wget https://cmake.org/files/v3.16/cmake-3.16.6.tar.gz
[root@localhost cmake]# tar -zxvf cmake-3.16.6.tar.gz
## 5. 安装基本工具
[root@localhost cmake]# yum install -y gcc gcc-c++
## 6. 进行编译连接
[root@localhost cmake]# cd cmake-3.16.6
[root@localhost cmake]# ./configure –prefix=/usr/local/cmake
## 7. 安装
[root@localhost cmake-3.16.6]# make && make install
## 8. 创建链接
[root@localhost cmake-3.16.6]# ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
## 9. 查看版本
[root@localhost cmake-3.16.6]# cmake -version
cmake version 3.16.6
CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@localhost cmake-3.16.6]#
[root@localhost cmake-3.16.6]#
如果第9步不想创建链接的话,也可以修改环境变量
[root@localhost ~]# vim /etc/profile
…
export CMAKE_HOME=/usr/local/cmake
export PATH=$PATH:$CMAKE_HOME/bin
## 刷新配置
[root@localhost ~]# source /etc/profile
转自:https://blog.csdn.net/huangchonghai/article/details/122250051
原创文章,作者:1402239773,如若转载,请注明出处:https://blog.ytso.com/275163.html