CentOS 7 安装CMake指定版本3.21.2

背景:今天在CentOS 7 电脑上安装C++ 日志框架SpdLog-1.12.0,提示如下错误信息:

[root@localhost build]# cmake .. && make -j
CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
  CMake 3.10...3.21 or higher is required.  You are running version 2.8.12.2


-- Configuring incomplete, errors occurred!

结论:SpdLog 日志框架要求编译的Cmake版本最低3.10 或3.21,我现在运行的版本仅为2.8.12.2 版本。

CentOS 7 安装CMake-3.21.2版本

第一步:下载CMake 源码

官网地址:https://github.com/Kitware/CMake

选择tags,下载自己所需的目标版本。

CentOS 7 安装CMake 指令

# 移除本地cmake
[root@localhost build]# yum remove cmake
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 cmake.x86_64.0.2.8.12.2-2.el7 将被 删除
--> 解决依赖关系完成

依赖关系解决

================================================================================================================================================
 Package                        架构                            版本                                       源                              大小
================================================================================================================================================
正在删除:
 cmake                          x86_64                          2.8.12.2-2.el7                             @base                           27 M

事务概要
================================================================================================================================================
移除  1 软件包

安装大小:27 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : cmake-2.8.12.2-2.el7.x86_64                                                                                                 1/1
  验证中      : cmake-2.8.12.2-2.el7.x86_64                                                                                                 1/1

删除:
  cmake.x86_64 0:2.8.12.2-2.el7

完毕!
[root@localhost build]# cd ..
[root@localhost spdlog-1.12.0]# cd ..
[root@localhost source_code]# ll
# 解压上传的cmake
[root@localhost source_code]# tar -zxvf CMake-3.21.2.tar.gz
CMake-3.21.2/
CMake-3.21.2/.clang-format
CMake-3.21.2/.clang-tidy
CMake-3.21.2/Auxiliary/
CMake-3.21.2/Auxiliary/CMakeLists.txt
*****
# 项目编译
[root@localhost CMake-3.21.2]# ./bootstrap
---------------------------------------------
CMake 3.21.2, Copyright 2000-2021 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++  -std=gnu++1y
Makefile processor on this system is: gmake
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
******

CMake has bootstrapped.  Now run gmake.
# 项目本地安装
[root@localhost CMake-3.21.2]# make && make install
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/ProcessUNIX.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/Base64.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/EncodingC.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/MD5.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/Terminal.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/System.c.o
******
# 验证本机cmkae 版本信息
[root@localhost CMake-3.21.2]# cmake -version
cmake version 3.21.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
相关推荐
诚信爱国敬业友善11 分钟前
GUI编程(window系统→Linux系统)
linux·python·gui
sekaii12 分钟前
ReDistribution plan细节
linux·服务器·数据库
YH_DevJourney1 小时前
Linux-C/C++《C/8、系统信息与系统资源》
linux·c语言·c++
威哥爱编程1 小时前
Linux驱动开发13个实用案例
linux
去看日出2 小时前
Linux(centos)系统安装部署MySQL8.0数据库(GLIBC版本)
linux·数据库·centos
qq_448941082 小时前
10、k8s对外服务之ingress
linux·容器·kubernetes
D-river3 小时前
【如何基于Debian构建Kali Linux】
linux·网络·安全·网络安全
年轮不改3 小时前
ARM-Linux 基础项目篇——简单的视频监控
linux·arm开发
m0_748238783 小时前
Nginx 负载均衡详解
运维·nginx·负载均衡
EasyNVR4 小时前
EasyRTC:全平台支持与自研算法驱动的智能音视频通讯解决方案
运维·服务器·小程序·音视频·webrtc·p2p·智能硬件