Installing the latest CMake on Ubuntu 18.04
This tutorial will show you how to install the latest version of CMake (3.16.5 as of writing) on Ubuntu 18.04.
The version of CMake installed by APT on Ubuntu 18.04 is currently 3.10.2. This version might not be new enough for some software, so this tutorial will show you how to remove the old version and update it to the latest using either Snappy or building from source.
Remove older version of CMake
If you’ve already installed CMake using the Ubuntu package manager, you’ll want to remove it by running the following commands:
sudo apt remove --purge cmake hash -r
Install the latest CMake
As of writing the latest version of CMake is 3.16.5 which can be installed using one of the following two options:
Option 1: Use Snappy
Using the Snappy package manager is the easiest way to install it and can be done by running the following command:
sudo snap install cmake --classic
You can check to see if it’s installed by running:
Option 2: Install from source
sudo apt install build-essential libssl-dev wget https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5.tar.gz tar -zxvf cmake-3.16.5.tar.gz cd cmake-3.16.5 ./bootstrap make sudo make install
After running the above commands, the latest version of CMake should now be installed. If you need to install a different version, head over to the download page on the CMake website to see the available versions then change the
wget command above.