Debian

How to Install CMake on Debian 11

CMake is a free and easily available open-source tool that manages the build process in an OS. It is important to note that CMake does not build any software; it just helps in the building process. It is the compiler-independent method used to generate the build files for different build systems. CMake is a tool created by Kitware for a much more powerful environment that is used as an open-source project like VTK, ITK, etc.

In this post, you will learn how to install CMake on Debian 11 using the following ways:

Prerequisites:

To install CMake on Debian 11, users must have sudo rights.

Method 1: Installing CMake Using Software Center (GUI)

In this GUI method, we will install CMake from Debian Software Center. Complete the following steps in order to install CMake on Debian:

To begin the installation, open the Software Center in your system from the applications menu. Look for CMake application using the search button.

Once the application icon appears in the search result, click it to open the following window. Now, click Install to begin the installation of CMake on your Debian system.

Then, provide your password for authentication. After that, it begins the installation. Once CMake is installed, you will see the following window:

Method 2: Installing CMake Using Tar.gz Archive (Command Line)

In this method, we will install the latest version of CMake using the command line. Complete the following steps in order to install CMake on Debian:

Step 1: Download CMake

As the official repository of Debian does not include CMake, we will use the tar.gz package available at the CMake official site.

Launch the terminal utility using the Ctl+Alt+T keyboard shortcut in your Debian system. Then, run the following command to download the CMake tar.gz package:

$ wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2.tar.gz

The package is saved in your current Terminal directory as cmake-3.24.2.tar.gz. The CMake v3.24.2 is the latest version as of September 2022.

Step 2: Extract CMake and Run the Bootstrap

Now, you are required to uncompress the downloaded tar.gz archive. Run the following command to uncompress the cmake-3.24.2.tar.gz archive file:

$ tar -zxvf cmake-3.24.2.tar.gz

It will uncompress the archive into a new directory cmake-3.24.2. Move into this directory using the cd command:

$ cd cmake-3.24.2

Once inside the cmake-3.24.2 directory, run the bootstrap script using the following command in the Terminal window:

$ sudo./bootstrap

Once the command is finished, you will see the following similar output:

Step 3: Install CMake

You can install CMake by following the two simple steps. First, run the cmake command:

$ make

Then, use the following command to install CMake:

$ sudo make install

Step 4: Verify Installation

To verify the installation of CMake, use the following command:

$ cmake --version

An output similar to the following screenshot that shows the CMake version will confirm the successful installation of CMake. If you do not receive such output, try again to perform the previously-mentioned steps.

Uninstall CMake

Based on how you installed CMake, there are two ways to remove it:

1. If you installed CMake via GUI, launch the Software Center, go to the Installed tab, and select CMake. Then, click Remove in order to uninstall CMake from your system.

2. If you installed CMake via the command line using the tar.gz archive, use the following method:

Move into the CMake directory which, in our scenario, is cmake-3.24.2:

$ cd cmake-3.24.2/

Then, run the following command to uninstall CMake:

$ sudo make uninstall

Conclusion

In this post, we covered the installation of CMake on Debian 11 using two different ways. Based on your preferences, you can choose either the graphical or command line method to install CMake. We also covered how to uninstall CMake if in case you need to remove it from your Debian system.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.