进入cmake的官网 https://cmake.org/download/ 以3.14.0版本为例可以发现,有很多种类型。如下图:
Latest Release (3.14.0)
The release was packaged with CPack which is included as part of the release. The .sh files are self extracting gziped tar files. To install a .sh file, run it with /bin/sh and follow the directions. The OS-machine.tar.gz files are gziped tar files of the install tree. The OS-machine.tar.Z files are compressed tar files of the install tree. The tar file distributions can be untared in any directory. They are prefixed by the version of CMake. For example, the Linux-x86_64 tar file is all under the directory cmake–Linux-x86_64. This prefix can be removed as long as the share, bin, man and doc directories are moved relative to each other. To build the source distributions, unpack them with zip or tar and follow the instructions in Readme.txt at the top of the source tree. See also the CMake 3.14 Release Notes. Source distributions:
Platform | Files |
Unix/Linux Source (has \n line feeds) | cmake-3.14.0.tar.gz |
cmake-3.14.0.tar.Z | |
Windows Source (has \r\n line feeds) | cmake-3.14.0.zip |
Binary distributions:
Platform | Files |
Windows win64-x64 Installer: Installer tool has changed. Uninstall CMake 3.4 or lower first! | cmake-3.14.0-win64-x64.msi |
Windows win64-x64 ZIP | cmake-3.14.0-win64-x64.zip |
Windows win32-x86 Installer: Installer tool has changed. Uninstall CMake 3.4 or lower first! | cmake-3.14.0-win32-x86.msi |
Windows win32-x86 ZIP | cmake-3.14.0-win32-x86.zip |
Mac OS X 10.7 or later | cmake-3.14.0-Darwin-x86_64.dmg |
cmake-3.14.0-Darwin-x86_64.tar.gz | |
Linux x86_64 | cmake-3.14.0-Linux-x86_64.sh |
cmake-3.14.0-Linux-x86_64.tar.gz |
这段话大概的意思是“一般开放源代码软件都会有两个版本发布:Source Distribution 和 Binary Distribution,前者是源代码版,你需要自己编译成可执行软件。后者是已经编译好的可执行版,直接可以拿来用的。”
安装步骤:
- 打开官方 https://cmake.org/download/ ,在source distributions 中找到Platform为Unix/Linux Source(has \n line feeds)的压缩包cmake-3.14.0.tar.gz,直接下载。可以直接下载,那么默认下载到download中或者你单独给它建立一个文件夹,把它放在你指定的文件夹中。
- Ctrl+Alt+T打开终端,利用切换指令cd切换到压缩包所在文件夹,如:cd /home/Danny/download 其中Danny是指我的账户名,直接换成你的账户名就可以。假如这个过程中你不太明白切换路径,那你一个文件夹一个文件夹切进去,并用ls指令看当下文件夹所包含的目录。
- 进行解压tar zxvf cmake-3.14.0.tar.gz 这样会得到一个解压文件是一个单独的文件夹,名称为cmake-3.14.0 。
- 这个时候你去看自己文件夹,如果有个锁说明有权限设置,需要用指令并修改文件权限chmod -R 777 cmake-3.14.0 。如果没有的话省略第4步。
- 检测gcc和g++是否安装,如果没有则需安装gcc-g++:sudo apt-get install build-essential(或者直接执行这两条命令sudo apt-get install gcc,sudo apt-get install g++)
- 利用cd指令切换到解压的文件下。我当时把解压文件夹移动到home下了,于是我的切换命令如下:cd /home/Danny/cmake.3.14.0
- 执行sudo ./bootstrap
- 执行sudo make
- 执行sudo make install
- 执行 cmake –version,返回cmake版本信息,则说明安装成功