1.在官网下载对应版本的包
https://cmake.org/download/
注意32位和64 位一定要区分开
2.如果是下载的含有source标签的则是源代码文件,需要自己编译,如果下载的是Binary distributions对应的则是已经编译好的版本,只需要添加环境变量就行。
3.一下以安装源文件版本为例
下载源文件后解压,进入文件目录
sudo ./bootstrap
遇到
---------------------------------------------
CMake 3.10.0, Copyright 2000-2017 Kitware, Inc. and Contributors
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find a C++ compiler supporting C++11 on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /home/javascript/下载/cmake-3.10.0/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
原来是没有装c++的编译器
ubuntu: apt-get install gcc g++
CentOS:yum install gcc gcc-c++
4.再次执行sudo ./bootstrap,成功结果如下
---------------------------------------------
CMake has bootstrapped. Now run make.
5.执行
sudo make
编译完成部分结果如下:
[ 99%] Linking C executable pseudo_tidy
[ 99%] Built target pseudo_tidy
Scanning dependencies of target pseudo_cppcheck
[ 99%] Building C object Tests/RunCMake/CMakeFiles/pseudo_cppcheck.dir/pseudo_cppcheck.c.o
[ 99%] Linking C executable pseudo_cppcheck
[ 99%] Built target pseudo_cppcheck
Scanning dependencies of target foo
[100%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX static library libfoo.a
[100%] Built target foo
6.执行
sudo make install
执行完成之后输入
cmake --version
查看版本和下载的是否一致,我下载的3.10.0
cmake --version
cmake version 3.10.0
安装完成
网友评论