背景:今天在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).