源码安装cmake-3.21.4版本方法:
#官方下载源码包
[root@localhost ~]# wget https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4.tar.gz
#解压到指定路径
[root@localhost ~]# tar xf cmake-3.21.4.tar.gz -C /usr/src/
#进入到解压目录
[root@localhost ~]# cd /usr/src/cmake-3.21.4/
#预配置 && 编译 && 安装
[root@localhost cmake-3.21.4]# ./configure && gmake && gmake install
采用源码安装cmake3.21.4版本时报错如下:
报错内容解释:cmake安装需要依赖openssl,安装cmake时要不提前安装openssl-devel要不预配置的时候通过-DCMAKE_USE_OPENSSL=OFF参数来跳过openssl依赖
CMake Error at Utilities/cmcurl/CMakeLists.txt:525 (message):
Could not find OpenSSL. Install an OpenSSL development package or
configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL
解决方案:
方案一、通过yum来安装openssl-devel
yum -y install openssl-devel
方案二.、在预配置的时候通过指定参数来跳过openssl依赖
./configure ---DCMAKE_USE_OPENSSL=OFF && gmake && gmake install
注:我实际项目是选择的第一种方案来解决的