源码编译步骤
-
安装依赖
# 安装依赖
sudo apt install build-essential
sudo apt install libssl-dev
-
最新版下载 Download | CMake 即 https://cmake.org/download/
-
CMake各版本文件链接:Index of /files
# 编译安装方式
# 下载
wget https://cmake.org/files/v3.26/cmake-3.26.0-rc2.tar.gz
# 解压
tar -xvzf cmake-3.26.0-rc2.tar.gz
# 编译
cd cmake-3.26.0-rc2
./configure
make
# 安装
sudo make install
# sh安装方式
wget https://cmake.org/files/v3.29/cmake-3.29.0-linux-x86_64.sh
chmod a+x cmake-3.29.0-linux-x86_64.sh
bash cmake-3.29.0-linux-x86_64.sh --help
sudo bash cmake-3.29.0-linux-x86_64.sh --prefix=/usr/local --exclude-subdir=true
环境配置
-
系统的cmake路径是/usr/bin/cmake
-
上述 sudo make install 安装的cmake位于/usr/local/bin下
-
需要将新安装cmake为系统默认的cmake,如下
update-alternatives --list cmake sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force
-
查看版本
cmake --version