How to install CMake on Ubuntu

CMake is a powerful, open-source tool used to build software on multiple platforms. It has quickly become the standard for C and C++ applications over the years. CMake is not only just a build system, it’s a meta build system that takes your source code and generates native project files for the target platform. This allows you to use the same code on different platforms without having to worry about the differences in build systems. CMake supports builds that can be in-place or out-of-place, so you can have numerous builds from the same source tree.

Before getting any further, we assume that you have a basic understanding of how the Linux shell works and how we send commands to it. You also need to know how to run terminal commands under root privileges in the safe way using sudo.

This article is going to show you how to install CMake on Ubuntu using a few different methods.


Ensure you have the proper root privileges and that your system is up to date before installing CMake with the commands below.

sudo apt update sudo apt upgrade

Install CMake with Ubuntu Software

If you don’t want to go about executing a bunch of commands on the Linux Terminal, then this method is for you. As of writing this post, the available stable version of CMake is 3.17.3.

Step 1. First, you have to open up the Ubuntu applications menu and search for “Ubuntu Software”, like what’s shown in the picture below.

Ubuntu Software

Step 2. In the Ubuntu Software catalog, click the search button or press Ctrl + F and search for CMake. You may see many different applications show up in the search result, but look for the item with the “triangle” icon, that’s the package we need. In the picture below, you can see two separate CMake section, as Ubuntu now supports two different way of installing applications. In this case, we can just select the first one as it is more popular.

search for CMake

Step 3. After clicking on the “Install” button, you will be asked to enter your root password. This is required in order to continue with the installation of CMake on your Ubuntu system.
clicking on the "Install" button

Step 4. Once CMake has been successfully installed, you can launch it from Ubuntu applications menu. CMake should start up and show a GUI window like this:

Launch CMake

Install CMake using snap

Snap is the new way of installing software on Linux systems. With snaps, you can install all of an app’s dependencies with a single command, and updates are automatic and resilient. Plus, apps run in their own isolated sandbox, thus minimizing security risks.

In order to install CMake using snap, first, you need to launch the Ubuntu Terminal and execute the command below.

sudo snap install cmake --classic

You may be asked to input your password, as the command needs root privileges to run the installer.

Once the installation completes, you can run MARKDOWN_HASH272ceadb8458515b2ae4b5630a6029ccMARKDOWNHASH with the “–version_” flag to be really sure that the program is installed properly.

Install CMake from source

While CMake can be installed using the methods mentioned above, none of them gives you the latest version. The actual source code of the program needs to be packaged, and sometimes tested for compatibility before being put up to the official software repository.

If you need the most recent version, you can follow the steps below to install CMake from the latest source code. The source code can be downloaded from CMake’s official website.

Step 1. Run the following command to install the libraries which CMake depends on.

sudo apt-get install build-essentials libssl-dev
Code language: JavaScript (javascript)

Step 2. Download the source code from Cmake website. You can either do that using a web browser or run the following command.

Code language: JavaScript (javascript)

Step 3. Extract the contents of the file using tar. After that, navigate to the newly extracted file contents.

tar -zxvf cmake-3.23.0-rc1.tar.gz cd cmake-3.23.0-rc1
Code language: CSS (css)

Step 4. Sequentially run the following commands to compile and install CMake to your system

sudo ./bootstrap make sudo make install

And that’s it – CMake is now installed! you can verify it by running cmake --version. You should be able to see the version number 3.23.0-rc1 in the output.

Leave a Comment