How to Install CMake on Rocky Linux 9

Advertisement

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 to only work with specific languages or operating systems, CMake can be used with any programming language and on any platform. This makes it an ideal choice for developers who want the flexibility to work on various projects. CMake is also constantly being updated with new features and improvements, so developers can be confident that they are using an always up-to-date tool. With its many benefits, it’s no wonder that CMake has become so popular in recent years.

In the following tutorial, you will learn how to install CMake on Rocky Linux 9 workstation or server using the command line terminal with two methods: dnf package manager with the native app-stream or compile method.

Update Rocky Linux

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

sudo dnf upgrade --refresh -y

Install CMake – DNF Method

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

Advertisement

To begin the installation, use the following command.

sudo dnf install cmake

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

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

Advertisement

Next, download the archive using the wget command.

Example only:

wget https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0.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.

Advertisement
cd cmake-{version number}

Optionally, move the CMake directory under /opt/ location.

sudo mv cmake* /opt/

Now, navigate to the directory.

Advertisement

cd /opt/cmake-{your version}

In the next part, you will execute the Bootstrap script. If you encounter any issue, ensure that the dependencies mentioned are installed.

sudo ./bootstrap

Example output once complete:

How to Install CMake on Rocky Linux 9

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 Rocky Linux 9

Next, install CMake using the following make install command.

Advertisement
Advertisement

sudo make install

Example output:

How to Install CMake on Rocky Linux 9

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 Rocky Linux 9

Comments and Conclusion

In short, CMake is a powerful and versatile compiler that has gained immense popularity in the past few years. Its open-source and cross-platform nature make it an attractive option for developers of all levels. In contrast, its ability to generate wrappers and executables makes it an excellent choice for any project.

For further reading, visit CMake’s official documentation.

Advertisement

Share on: