Friday, September 2, 2022

Ubuntu: Upgrade to the latest cmake

Ubuntu 20.04.4 LTS allows cmake to be installed as follows using -y to suppress the prompt:

sudo apt-get update && sudo apt-get install -y cmake

The cmake installed is not the latest version as can be seen using cmake --version:

To install the latest version of cmake, first uninstall cmake (if it is already installed and that it was installed using apt-get):

sudo apt-get remove -y cmake

Latest cmake Install

The cmake releases can be found at:

The following script downloads and installs a specific version of cmake (version 3.24.1):

wget \
  -q -O /tmp/ \
&& chmod u+x /tmp/ \
&& sudo mkdir /opt/cmake-3.24.1 \
&& sudo /tmp/ --skip-license --prefix=/opt/cmake-3.24.1 \
&& rm /tmp/ \
&& sudo ln -s /opt/cmake-3.24.1/bin/* /usr/local/bin

To verify the correct version of cmake is installed invoke cmake --version:

cmake Uninstall

Obviously "sudo apt-get remove -y cmake" cannot be used to uninstall cmake installed via

The following steps uninstall cmake, be versing the steps used to install cmake above which used to install cmake:

pushd . \
&& cd /usr/local/bin \
&& ls /opt/cmake-3.24.1/bin | \
  sudo xargs rm \
&& sudo rm -rf /opt/cmake-3.24.1 \
&& popd

No comments :

Post a Comment