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).

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值