How to Install CMake on Debian 10/11/12

Here you will find two different methods to install CMake on your Debian machine.

While building the application from the source, I get the error occurs CMake: command is not found, and due to that, I cannot install OBS-Studio on my Debian 12.

This error mainly occurs when your system does not have CMake installed.

Okay, I got it, but what is CMake?

CMake is a cross-platform open-source tool to build packages using CMakeLists to generate builds for a specific environment. It was created by Bill Hoffman at Kitware and supports multiple native build environments.

Now you get the idea why CMake is necessary during the installation process, right? So let’s open your system terminal and follow the steps below to install CMake on your Debian 10/11/12 system.

Install CMake on Debian and Ubuntu

CMake can be installed in multiple ways, like from system repositories or from the source file. Here we will show you both ways to install CMake on your Debian machine.

Steps to Install CMake on Debian 10/11/12 From Repositories

One of the simplest and easiest ways to get CMake installed on your system is to use system repositories. In which you just need to update your system repositories and run one line of command to install CMake.

Now bring the terminal in front of your screen and execute the following commands in sequence:

$ sudo apt update -y
$ sudo apt install cmake -y

After that, execute the below command to verify the installation.

$ cmake --version    
CMake installed from repository version
CMake installed from the repository version

If the version is displayed, your work is over, and you can now continue with the steps that threw the CMake command not found error.

Pretty simple, right? Of course it is, but the only problem with this method is that you won’t find the latest version of CMake.

Steps to Install CMake on Debian 10/11 From Source

To get the latest version of CMake, you can follow these steps, where I’ll show you how to get the latest release of CMake from the official website and install it on your system.

Before proceeding ahead, I will suggest you install the following package for a smooth experience:

$ sudo apt install build-essential gcc libssl-dev

Once you are done with the above command, let’s download the CMake Script file.

Step 01Download CMake Script

To get the latest version of CMake, you can visit their official web page or go to the release section on Github and download the new release that is available to you.

Here I’m downloading the latest release of CMake over the RC release using the wget command, as shown below:

$ wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh

cmake-3.26.4-linux-x86_64.sh 100%[=========================================>]  46.09M  6.10MB/s    in 7.9s    

2023-06-28 19:42:00 (5.86 MB/s) - ‘cmake-3.26.4-linux-x86_64.sh’ saved [48323148/48323148]

Step 2Run Script file to Install CMake

Once the script file is downloaded, you can simply execute the next line of command to install CMake in the /usr/local/ directory by excluding the cmake-3.26.4-linux-x86_64 directory name.

$ sudo sh cmake-3.26.4-linux-x86_64.sh --prefix=/usr/local/ --exclude-subdir    

But before executing the above command, I suggest you get an overview of the shellscript so you can understand what each step does.

To check that you can use the following command:

$ less cmake-3.26.4-linux-x86_64.sh

Once you are done with inspection, execute the final command:

$ sudo sh cmake-3.26.4-linux-x86_64.sh --prefix=/usr/local/ --exclude-subdir    

The output of the above command

Install CMake from script in Linux
Install CMake from script in Linux

Step 3Check CMake Version

Your work is almost over here, and you are now just left with the step of checking the version of CMake you have installed on your system.

To check run cmake --version

CMake version
CMake version

If you are getting the same output as shown above, then your work is over here, so you can now move on to the next steps of your project.

Wrapping up

That’s all for this article, in which I shared with you two different ways to install CMake on your Debian-based system. If you are not getting anything or want to give some suggestions, feel free to comment down below.

Also Read : Building Programs from Source on any Linux Distribution in a simple way

See you in the next article…SPREAD LOVE AND PEACE.

0 0 votes
Article Rating
Subscribe
Notify of
guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
AlexS
AlexS
2 years ago

Thank you very much.
I have installed on new Debian 11. It works very well!

PJ
PJ
2 years ago

at least use checkinstall for your your make install bit so it can be easily uninstalled later if a properly packaged version comes out.

likalium
likalium
2 years ago

thx you!!!!