来源:https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line
1. 删除旧版本的 cmake
apt remove --purge --auto-remove cmake
apt purge --auto-remove cmake
2. 安装包源
apt update && apt install -y software-properties-common lsb-release
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
可选操作
apt update
apt install kitware-archive-keyring
rm /etc/apt/trusted.gpg.d/kitware.gpg
如果执行 apt update
报错,并且错误中有 the public key is not available: NO_PUBKEY 6AF7F09730B3F0A4
,则执行如下操作把这个 key 添加到系统里面
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
3. 安装最新版 cmake
可以先使用 apt search cmake
查看默认 cmake
包的版本,然后执行下面的命令进行安装
apt update
apt install cmake
4. 安装编译工具
apt install build-essential libtool autoconf unzip wget