Install CMake on Debian 11 Bullseye

CMake is a free, open-source, and cross-platform compiler designed to build native environments, generate wrappers, build executables in arbitrary combinations. CMake is popular due to its cross-platform so that developers using the build system work the way they’re used to.

In the following tutorial, you will learn how to install CMake on Debian 11 Bullseye Desktop or Server.

Prerequisites

  • Recommended OS: Debian 11 Bullseye.
  • User account: A user account with sudo or root access.
  • Internet Access

The tutorial will utilize the terminal for the installation found in Activities > Show Applications > Terminal.

Example:

Install 510 NVIDIA Drivers on Debian 11 Bullseye

Update Operating System

Update your Debian operating system to ensure all existing packages are up to date.

sudo apt update && sudo apt upgrade -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@debian~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Debian.

Use the following command with the root password to log in to use the root account. 

su

For users that have sudo access, this can be skipped.

Option 1 – Install CMake with APT Repository

The first method recommended for most users will install CMake from Debian 11’s repository.

To begin the installation, use the following command.

sudo apt install cmake

Example output:

Install CMake on Debian 11 Bullseye

Type Y, then press the ENTER KEY to proceed.

Once installed, confirm the installation by checking the version of CMake.

cmake --version

Example output:

cmake version 3.18.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Option 2 – Install CMake by Compiling Source

The second option for users requiring the latest version of CMake is downloading the source and compiling it. This is an excellent method as it allows you to install the newest version, but it comes at the cost of remembering to download and re-compile for updates.

Before proceeding further, install the following required dependencies on your system using the following command.

sudo apt install build-essential checkinstall zlib1g-dev libssl-dev -y

First, visit the Github releases page and grab the latest version link, do not forget to do this as the examples link below will be outdated in time.

Next, download the archive using the wget command.

Example only:

wget https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2.tar.gz

Extract the archive contents using the following command.

tar -zxvf cmake-{version number}.tar.gz

Now CD into the directory that was extracted.

cd cmake-{version number}

In the next part, you will Bootstrap script. If you encounter any issues, make sure the dependencies mentioned further up are installed.

./bootstrap

The Bootstrap script may take a few minutes. Once done, use the make command to build the package.

make

Next, install CMake using the following make install command.

make install

This process can take a few minutes to almost ten minutes to make a coffee or grab a drink.

Once the installation has finished, check the CMake version.

cmake version 3.22.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

As above, you have successfully installed version 3.22.2 instead of the default Debian APT version of 3.18.4.

Comments and Conclusion

In the tutorial, you have learned two ways to install CMake on your Debian 11 Bullseye desktop or server, along with the dependencies required.

Overall, if you are looking into development and programming or running a server with services, you will often come across this package.

For further reading, visit CMake’s official documentation.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!