How to Install CMake on Rocky Linux EL9 or EL8

CMake is a cross-platform open-source build system that is widely used for software development. It is designed to be used in conjunction with other build systems to generate native build files for a variety of platforms. CMake can be used to build, test, and package software, as well as to generate project files for popular IDEs such as Visual Studio and Xcode. One of the reasons why CMake is so popular is that it is designed to be easy to use, and it is supported by a wide variety of compilers and platforms.

On a Rocky Linux system, CMake can be used to manage the building, testing, and packaging of software. It is particularly useful when working with large and complex projects that need to be built on multiple platforms.

In this guide, you will discover how to install CMake on a Rocky Linux 9 or 8 system, either through the command line terminal using the dnf package manager and the native app-stream, or by compiling it from source. Two methods will be presented for your convenience.

Step 1: Update Rocky Linux

First, make sure your system is up-to-date by running an update on all existing packages.

sudo dnf upgrade --refresh

Method 1: Install CMake with DNF

The first method recommended for most users is to install CMake from the appstream. This version is the default and is recommended for most users, unless you need a specific version or the latest version, in which case you will need to use the compile method. To begin the installation, use the following command.

sudo dnf install cmake

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

cmake --version

Method 2: Install CMake with Source

The second method for installing CMake is by downloading the source code and compiling it. This method allows you to install the latest version of CMake, however, it comes with the responsibility of remembering to download and re-compile the source code for updates.

Before beginning the installation process, you will need to install some required dependencies on your system. You can do this by running the following command.

sudo dnf install gcc gcc-c++ openssl-devel bzip2-devel libffi-devel zlib-devel make -y

First, visit the Github releases page and grab the latest version link.

Next, download the archive using the wget command.

Example only:


Extract the archive using the following command.

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

Change directory into the extracted folder using the following command.

cd cmake-{version number}

In the next step, you will run the Bootstrap script. It is important to ensure that all the required dependencies mentioned earlier are installed, as this may cause issues if not done so.


Example output once complete:

Once the Bootstrap script is completed, use the make command to build the CMake package. This process may take several minutes to complete.


This process may take several minutes, so you may want to take a break or grab a drink while you wait.

Example when complete:

The next step is to install CMake using the command “make install”.

sudo make install

Example output:

Once completed, you can verify the installation by checking the version of CMake using the following command.

cmake --version

Example output:

cmake version 3.25.2

CMake suite maintained and supported by Kitware (


In conclusion, installing CMake on Rocky Linux is a straightforward process that can be done through two methods: using the dnf package manager with the native app-stream or compiling from source. Both methods will install the latest version of CMake, but the app-stream method is recommended for most users as it is simpler and does not require additional steps for updates. The compile method is recommended for users who require the latest version of CMake or a specific version. Regardless of the method chosen, it is essential to confirm the installation by checking the version of CMake to ensure it has been installed correctly.

For further reading, visit CMake’s official documentation.

Share to...