How to Install CMake on CentOS 9 Stream

CMake is a well-known compiler that has gained much popularity in recent years. The main reason for its popularity is that it is open-source and cross-platform, so developers can use it on any operating system they want and don’t have to worry about licensing fees. Additionally, CMake can generate wrappers and executables in any combination, making it very versatile. While some compilers are designed for specific tasks, CMake can be used for various projects, making it a popular choice for many developers.

The following tutorial will teach you how to install CMake on CentOS 9 Stream workstation or server using the command line terminal.

Update CentOS Stream

First, update your system to ensure all existing packages are up to date.

sudo dnf upgrade --refresh

Install CMake – DNF Method

The first method recommended for most users will install CMake from CentOS Stream’s appstream. This version is recommended unless you request a specific version or the latest, which you will need to use the compile method.

To begin the installation, use the following command.



sudo dnf install cmake

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

cmake --version

Install CMake – Compile Source Method

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 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.

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.24.0-rc3/cmake-3.24.0-rc3.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 execute the Bootstrap script. If you encounter any issue, ensure that the dependencies mentioned are installed.

sudo ./bootstrap

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

sudo make

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



Example when complete:

How to Install CMake on CentOS 9 Stream

Next, install CMake using the following make install command.

sudo make install

Once the installation has finished, check the CMake version.

Once done, confirm the version using the following command

cmake --version

Example output:

How to Install CMake on CentOS 9 Stream

Comments and Conclusion

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.


Not what you were looking for? Try searching for additional tutorials.

Leave a Comment