Linux CentOS Cmake

1、检查当前的cmake的版本

  1. [root@iZuligp6e1dyzfZ tools-software]# cmake --version
  2. cmake version 2.8.12.2

2、从Cmake官网获取下载的版本

cmake官网
https://cmake.org/
image.png

A.使用wget进行下载

  1. [root@iZuligp6e1dyzfZ tools-software]# wget https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1.tar.gz

B.安装包上传至服务器(国内访问比较慢时,可用)

cmake-3.18.1.tar.gz
cmake-3.22.1.tar.gz.zip下载后将.zip后缀去掉

3、解压安装

A.解压配置

  1. [root@iZuligp6e1dyzfZ tools-software]# tar -zxvf cmake-3.18.1.tar.gz
  2. [root@iZuligp6e1dyzfZ tools-software]# cd cmake-3.18.1
  3. [root@iZuligp6e1dyzfZ cmake-3.18.1]# ./configure

①报错-缺少SSL

  1. -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
  2. CMake Error at Utilities/cmcurl/CMakeLists.txt:485 (message):
  3. Could not find OpenSSL. Install an OpenSSL development package or
  4. configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.
  5. -- Configuring incomplete, errors occurred!
  6. See also "/local/tools-software/cmake-3.18.1/CMakeFiles/CMakeOutput.log".
  7. See also "/local/tools-software/cmake-3.18.1/CMakeFiles/CMakeError.log".
  8. ---------------------------------------------
  9. Error when bootstrapping CMake:
  10. Problem while running initial CMake
  11. ---------------------------------------------

解决办法
  1. [root@iZuligp6e1dyzfZ cmake-3.18.1]# rm -rf CMakeCache.txt
  2. [root@iZuligp6e1dyzfZ cmake-3.18.1]# yum -y install ncurses-devel
  3. [root@iZuligp6e1dyzfZ cmake-3.18.1]# yum install openssl-devel

②报错-C++编译版本太低

  1. [root@iZuf68qk0bio1l786kylamZ cmake-3.18.1]# ./configure
  2. ---------------------------------------------
  3. CMake 3.18.1, Copyright 2000-2020 Kitware, Inc. and Contributors
  4. C compiler on this system is: cc
  5. ---------------------------------------------
  6. Error when bootstrapping CMake:
  7. Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
  8. Please specify one using environment variable CXX.
  9. The C++ flags are "".
  10. They can be changed using the environment variable CXXFLAGS.
  11. See cmake_bootstrap.log for compilers attempted.
  12. ---------------------------------------------
  13. Log of errors: /root/cmake-3.18.1/Bootstrap.cmk/cmake_bootstrap.log
  14. ---------------------------------------------
  15. [root@iZuf68qk0bio1l786kylamZ cmake-3.18.1]# gcc --version
  16. gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
  17. Copyright (C) 2015 Free Software Foundation, Inc.
  18. This is free software; see the source for copying conditions. There is NO
  19. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

image.png

解决办法

升级g++,参考:
CentOS7.3安装升级gcc

③再次执行./configure

  1. [root@iZuligp6e1dyzfZ cmake-3.18.1]# ./configure

配置完成输出

  1. -- Performing Test run_pic_test - Success
  2. -- Performing Test run_inlines_hidden_test
  3. -- Performing Test run_inlines_hidden_test - Success
  4. -- Configuring done
  5. -- Generating done
  6. -- Build files have been written to: /local/tools-software/cmake-3.18.1
  7. ---------------------------------------------
  8. CMake has bootstrapped. Now run gmake.

B.安装

  1. [root@iZuligp6e1dyzfZ cmake-3.18.1]# make && make install

C.执行 hash -r

  1. [root@iZuligp6e1dyzfZ cmake-3.18.1]# hash -r

D.执行 cmake --version 查看安装的版本

  1. [root@iZuligp6e1dyzfZ cmake-3.18.1]# cmake --version
  2. cmake version 3.18.1
  3. CMake suite maintained and supported by Kitware (kitware.com/cmake).