How to Install CMake on Fedora 37/36/35

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. Given Fedora is an upstream-focused distribution on a six-month release schedule, most often, the latest CMake version is available to install, making the installation for developers requiring the latest packages very straightforward compared to some other Linux Distributions.

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

Recommended Steps Before Installation

Before you continue, your system is advised to ensure all existing packages are up to date to avoid system conflicts.

sudo dnf upgrade --refresh -y

#1st Method – Install CMake – Fedora Repository

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.

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

Example output:

cmake version 3.25.0-rc4

#2nd Method – Install CMake – Compile 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 dnf install gcc gcc-c++ openssl-devel bzip2-devel libffi-devel zlib-devel wget make -y

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

Do not forget to do this, as the examples below will be outdated.

Next, download the archive using the wget command.

Example only:

wget https://github.com/Kitware/CMake/releases/download/v3.25.0-rc4/cmake-3.25.0-rc4-linux-x86_64.tar.gz

Extract the archive contents using the following command.

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

Now, navigate to the directory.

cd /cmake-{your version}

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

./bootstrap

Example output once complete:

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

make

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

See also
How to Install Redis on Fedora Linux

Example when complete:

Next, install CMake using the following make install command.

sudo make install

Example output:

Once the installation has finished, check the CMake version.

Once done, confirm the version using the following command

cmake --version

Example output:

cmake version 3.25.0-rc4

For further reading, visit CMake’s official documentation.

Leave a Comment

Share to...