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).
相关推荐
大模型码小白2 分钟前
MCP协议开发实战:从零搭建AI Agent工具链
运维·人工智能·算法·机器学习·自动化
Syc1102g4 分钟前
在 Linux CentOS 系统中设置静态 IP
linux·网络·计算机网络·个人开发
2601_962203515 分钟前
Nginx 安装配置
运维·nginx
YQ_016 分钟前
ROS 2 Humble Nav2 生命周期教程:启动流程、状态监控、超时诊断与自愈设计
linux·机器人·ros2·nav2
loong_XL27 分钟前
Windows WSL2 Ubuntu 搭建 Xvfb 虚拟桌面环境,完美支持多 Agent 隔离
linux·windows·ubuntu
大熊背28 分钟前
树莓派 libcamera IPA 框架解析
linux·ipa·isppipeline
Horn Still Sounds36 分钟前
Linux进程间通信:信号、消息队列、共享内存完整笔记
linux·网络·笔记
拂拉氏37 分钟前
【知识讲解】 Linux进程的认识与创建
linux·进程
TDengine (老段)37 分钟前
TDengine 应用案例 — IT 运维与可观测性
大数据·运维·数据库·制造·时序数据库·tdengine·涛思数据
观无1 小时前
.net发布注意事项
运维·服务器