1、检查当前的cmake的版本
[root@iZuligp6e1dyzfZ tools-software]# cmake --version
cmake version 2.8.12.2
2、从Cmake官网获取下载的版本
A.使用wget进行下载
[root@iZuligp6e1dyzfZ tools-software]# wget https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1.tar.gz
B.安装包上传至服务器(国内访问比较慢时,可用)
cmake-3.18.1.tar.gz
cmake-3.22.1.tar.gz.zip下载后将.zip后缀去掉
3、解压安装
A.解压配置
[root@iZuligp6e1dyzfZ tools-software]# tar -zxvf cmake-3.18.1.tar.gz
[root@iZuligp6e1dyzfZ tools-software]# cd cmake-3.18.1
[root@iZuligp6e1dyzfZ cmake-3.18.1]# ./configure
①报错-缺少SSL
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
CMake Error at Utilities/cmcurl/CMakeLists.txt:485 (message):
Could not find OpenSSL. Install an OpenSSL development package or
configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.
-- Configuring incomplete, errors occurred!
See also "/local/tools-software/cmake-3.18.1/CMakeFiles/CMakeOutput.log".
See also "/local/tools-software/cmake-3.18.1/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------
解决办法
[root@iZuligp6e1dyzfZ cmake-3.18.1]# rm -rf CMakeCache.txt
[root@iZuligp6e1dyzfZ cmake-3.18.1]# yum -y install ncurses-devel
[root@iZuligp6e1dyzfZ cmake-3.18.1]# yum install openssl-devel
②报错-C++编译版本太低
[root@iZuf68qk0bio1l786kylamZ cmake-3.18.1]# ./configure
---------------------------------------------
CMake 3.18.1, Copyright 2000-2020 Kitware, Inc. and Contributors
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
The C++ flags are "".
They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /root/cmake-3.18.1/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
[root@iZuf68qk0bio1l786kylamZ cmake-3.18.1]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
解决办法
升级g++,参考:
CentOS7.3安装升级gcc
③再次执行./configure
[root@iZuligp6e1dyzfZ cmake-3.18.1]# ./configure
配置完成输出
-- Performing Test run_pic_test - Success
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /local/tools-software/cmake-3.18.1
---------------------------------------------
CMake has bootstrapped. Now run gmake.
B.安装
[root@iZuligp6e1dyzfZ cmake-3.18.1]# make && make install
C.执行 hash -r
[root@iZuligp6e1dyzfZ cmake-3.18.1]# hash -r
D.执行 cmake --version
查看安装的版本
[root@iZuligp6e1dyzfZ cmake-3.18.1]# cmake --version
cmake version 3.18.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).