CentOS7安装cmake-3.18.0

1.下载源码包
[root@test2 ~]# wget https://github.com/Kitware/CMake/releases/download/3.18.0/cmake-3.18.0.tar.gz

2.解压源码包到指定路径
[root@test2 ~]# tar -zxvf cmake-3.18.0.tar.gz -C /home/ops/

3.目录名优化
[root@test2 ~]# cd /home/ops/
[root@test2 /home/ops]# mv cmake-3.18.0 cmake

4.安装支持包
[root@test2 /home/ops]# yum -y install gcc gcc-c++ openssl-devel

5.编译安装
[root@test2 /home/ops]# cd /home/ops/cmake
[root@test2 /home/ops/cmake]# ./bootstrap
如果遇到如下图的报错,说明没有安装openssl-devel支持包,安装openssl-devel后删除源码目录下的CMakeCache.txt文件后重新bootstrap即可解决
在这里插入图片描述
make && make install

6.测试cmake命令
[root@test2 /home/ops/cmake]# ./bin/cmake

Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

#弹出Usage说明cmake安装完成

7.制作软链接
第5步完成之后会在源码目录下生成一个bin目录,cmake可执行文件就在bin目录下
[root@test2 /home/ops/cmake]# ln -s /home/ops/cmake/bin/cmake /usr/bin/cmake
[root@test2 /home/ops/cmake]# cmake

Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

#弹出Usage说明cmake安装完成

猜你喜欢

转载自blog.csdn.net/weixin_44901564/article/details/108225845