Home Ubuntu How to install CMake on Ubuntu

How to install CMake on Ubuntu

by Arun Kumar
Published: Last Updated on
CMake installation Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process. It leads to the production of native makefiles and workspaces, which are, in turn, used in a compiler environment of choice.

In this post, we are going to show you how to install CMake on your Ubuntu system. Our Ubuntu release of choice in this tutorial is Ubuntu 18.04 LTS.

Installing CMake on Ubuntu

Prerequisites

Before installing CMake, ensure you have root privileges and that your system is up to date by running the commands below.

sudo apt update
sudo apt upgrade

Method 1: Install CMake using 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. Launch the “Ubuntu Software Install” from the Ubuntu applications menu, as shown in the image below.

Launch Software Install from Ubuntu Applications

Launch Software Install from Ubuntu Applications

Step 2. On the Ubuntu Software “Search Bar” at the top, type the word CMake and press “Enter.” You will see a list of applications but only Click on the CMake icon. It will probably be the first item on the list, as shown in the image below.

Search for CMake in the Search Bar

Search for CMake in the Search Bar

Step 3. Click on the “Install” button to download and install CMake on your Ubuntu system. You might be required to enter your root password to continue with the installation.

Click on the Install button to install CMake in your system

Click on the Install button to install CMake in your system.

Step 4. You can track the installation progress using the percentage below, as shown in the image.

See the Installation progress on the Percentage bar

See the Installation progress on the Percentage bar.

CMake will now install in your system. If the process completes successfully, You should see a window similar to the one on the image below.

Launch CMake after a successful installation

Launch CMake after a successful installation

Step 5. To start CMake, click on the “Launch” button. The CMake window should open, as shown in the image below.

Launch CMake

Launch CMake

Uninstall CMake using the Ubuntu Software

If you wish to remove CMake from your system using the Graphical User Interface GUI), it is pretty straightforward.

Step 1. Launch the Ubuntu Software application and search for “CMake” on the search bar above.
Step 2. Click on the CMake application that appears on the list. You should see a window similar to the one below.

Launch CMake after a successful installation

Remove/Uninstall CMake.

Step 3. Click on the “Remove” button to uninstall CMake from your Ubuntu system.

Removing CMake on Ubuntu

Removing CMake on Ubuntu

From the image below, we can see “CMake” is uninstalling from your system.

Method 2: Installing CMake using command-line

This is the method to follow to install CMake in your Ubuntu system to those who prefer the Command-line method over the Graphical User Interface. There are two ways which you can use to install CMake on your system via the Terminal:

a) Using snap

b) Using the source code from the official CMake website

Snap app

Step 1. Launch the Ubuntu Terminal and execute the command below.

sudo snap install cmake –classic

Once the installation completes, run the “–version” command below to see the CMake version installed in your system.

cmake --version
Install CMake via snap

Install CMake via snap

To Remove/Uninstall CMake using snap in the command-line, run the command below.

sudo snap remove cmake

Note, this method only works for CMake installed via Snap or Graphical way using the Ubuntu Software.

Remove CMake using Snap

Remove CMake using Snap

Installing CMake using Source Code VI

Before writing this post, I tried installing CMake from the Ubuntu repository and PPA, but none of them installed the latest CMake version. To install the latest CMake version, follow the steps below.

Step 1. Download the CMake source code from its official website. That can be done using the “wget” command on the Terminal, as shown below. Make sure to replace the link in the below command with the link you copy from the official website.

$ wget https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3.tar.gz
Download Source code using wget

Download Source code using wget

Step 2. Navigate to the directory where you downloaded the code. It should be the folder in which you run the “wget” command. Run the “tar” command to extract the contents.

tar -zxvf cmake-3.17.3.tar.gz
Extract the source code using tar command

Extract the source code using tar command

Step 3. Navigate to the newly created CMake directory using the “cd” command.

cd cmake-3.17.3
Navigate to CMake directory

Navigate to CMake directory

Step 4. Run the command below to compile and install CMake in your Ubuntu system.

sudo ./bootsrap
Configure and Install CMake

Configure and Install CMake

Once the process completes, you should see a message, as in the image below.

CMake bootstrapped succesfully

CMake bootstrapped successfully

Step 5. Run the “make” command.

make
Run the make command

Run the make command

Step 6. Run the “make install” command to install CMake in your system.

make install
Make Install command

Make Install command

Step 7. To confirm that CMake installed successfully in your system, run the “version” command.

cmake --version
CMake version

CMake version

To Remove/Uninstall CMake installed using the “make” command, run the command below.

sudo make uninstall
Make Uninstall command

Make Uninstall command

Conclusion

Those are two ways to install CMake on your Ubuntu system. If you are new to using CMake and would like to know more about it, head over to the official site to read their comprehensive documentation.

You may also like

10 comments

gomfy September 3, 2020 - 8:02 PM

There are a couple typos e.g. `sudo snap install cmake -classic` should be `–classic`, or `sudo ./bootsrap` should be `bootstrap` etc.

Reply
Polish Guide September 16, 2020 - 1:53 PM

I am normally a language learner, but thrilled of what a detailed guide you made here today. You could learn alot from this. Very Polished detail.

Reply
Keipro October 7, 2020 - 4:16 AM

thanks for your instruction.
On “ubuntu 20.04” I couldnt install cmake in terminal “sudo snap install cmake -classic” I had to change it to “–classic” because I got ” error: unknown flag `c’ “

Reply
András Gyarmati April 27, 2021 - 12:54 PM

same, also get error: ./bootstrap: No such file or directory

Reply
Kiran Kumar September 7, 2021 - 9:43 AM

Thanks for the feedback. The typo is corrected.

Reply
Danna Balboa October 10, 2020 - 12:36 PM

thank you so much for this guide, really appreciate it

Reply
Bailey Moir December 17, 2020 - 5:55 PM

In the commands, you said sudo ./bootsrap instead of sudo ./bootstrap.

Reply
Vlad December 27, 2020 - 9:08 AM

it is “sudo snap install cmake –classic”

Reply
jarcos March 2, 2021 - 9:49 AM

There are a few issues with these instructions. In some cases in my Ubuntu 20 Virtual Machine you need to add – twice, as in sudo snap install cmake –-classic. Moreover, Step 4 of Method 2 has an obvious typo, sudo ./bootsrap should read bootstrap, with a second t, which may be confusing to users less experienced or with English as a second language. But in any case, it was helpful, thank you.

Reply
John Krawczyk September 6, 2021 - 4:35 PM

The command for installing CMake has a typo. Its should have “–classic” instead of “-classic” e.g. two of the dashes. The full line is thus:
sudo snap install cmake –classic

Reply

Leave a Reply to András Gyarmati Cancel Reply

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.