如果出现如下报错,就应该升级cmake了!
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.1 or higher is required. You are running version 2.8.12.2
-- Configuring incomplete, errors occurred!
官网
可以下载各个版本的cmake: https://cmake.org/files/
升级
1.下载cmake,这里选择cmake-3.12.4,当然可以选择更新的版本:
进入https://cmake.org/files/v3.12/
选择cmake-3.12.4.tar.gz
2.解压后进入文件夹进行编译编译
./bootstrap
make
sudo make install
3.查看版本
cmake --version
打印如下,说明安装成功了!
cmake version 3.12.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
-
问题1
---------------------------------------------
CMake 3.12.4, Copyright 2000-2018 Kitware, Inc. and Contributors
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
The C++ flags are "".
They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /home/hu/cmake-3.12.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
sudo apt-get install g++
安装完后,发现make会出报错如下:
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/bin
CMake Error: Error executing cmake::LoadCache(). Aborting.
解决
- 首推方法
hash -r
- 其他方法
sudo -E中
-E
选项在man page中的解释是:The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the -E option is specified and the user does not have permission to preserve the environment.简单来说,就是加上-E
选项后,用户可以在sudo执行时保留当前用户已存在的环境变量,不会被sudo重置,另外,如果用户对于指定的环境变量没有权限,则会报错。
sudo apt-get remove cmake cmake-data
sudo -E add-apt-repository -y ppa:george-edison55/cmake-3.x
sudo -E apt-get update
sudo apt-get install cmake
-
问题2
---------------------------------------------
CMake 3.18.5, Copyright 2000-2020 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate Makefile processor on this system.
Please specify one using environment variable MAKE.
---------------------------------------------
Log of errors: /home/hu/software/cmake-3.18.5/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
解决
sudo apt-get update
sudo apt-get install make
或者
sudo apt-get install build-essential
-
问题3
-- 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)
解决
sudo apt-get install libssl-dev