How to Install CMake on Fedora 39, 38 Linux

This guide will demonstrate how to install CMake on Fedora Linux using the command-line terminal. Options include using the DNF Package Manager with Fedora’s RPM or downloading and compiling the latest version’s source binary.

CMake is a robust, cross-platform build system that simplifies the process of managing software builds. Its modular design allows developers to control the build environment across various platforms efficiently. CMake automates the detection of dependencies and the build process, making it an indispensable tool for modern software development. It supports out-of-source builds, reducing clutter and enhancing the manageability of build files. The tool’s ability to generate native build environments, such as Unix Makefiles or Microsoft Visual Studio projects, is a key feature that streamlines the development workflow.

To understand CMake’s impact and capabilities, consider the following highlights:

  • Cross-Platform Support: CMake provides a unified interface across different operating systems, ensuring consistency in the build process.
  • Out-of-Source Builds: Allows separate source and build directories, preventing contamination of source tree.
  • User-Defined Build Configurations: Offers flexibility in creating custom build types.
  • Automatic Dependency Analysis: Efficiently manages and resolves dependencies within the project.
  • Scripting Capabilities: Includes a scripting language that allows for complex build configurations.
  • Testing Support: Integrates with testing frameworks to facilitate test-driven development.
  • GUI and Command Line Invocation: Caters to various user preferences and automation scripts.
  • Extensibility: Supports custom modules and user-contributed scripts to expand functionality.

Now, let’s dive into the technical steps to install CMake on Fedora Linux, ensuring you have the necessary tools and environment for your development projects.

Install CMake on Fedora via DNF

The first method suits most users and developers, as Fedora is an upstream-focused distribution. For those who require the absolute latest version of CMake, check out the second section.

Update Fedora Before CMake Installation

Update your Fedora system before installing CMake to ensure all packages are current and minimize potential conflicts or issues during installation.

Run the following command in your terminal to update Fedora:

sudo dnf upgrade --refresh

Install CMake via DNF Command

For most users, installing CMake from Fedora’s AppStream repository is recommended. This well-tested and stable version is ideal for general use.

Run the following command in your terminal to install CMake:

sudo dnf install cmake

Verify Installation of CMake

Once you have installed CMake, verify the installation by checking the version. This confirmation ensures a successful installation and the availability of CMake on your system.

To check the CMake version, run the following command:

cmake --version

Install CMake on Fedora via source

This method benefits users who require the latest version of CMake or a specific version not available in the Fedora repository. However, it is essential to remember that updating CMake with this method requires manually downloading and re-compiling the source code.

Install Initial Packages Required For CMake

Before proceeding, ensure your system has all the required dependencies for building CMake. You can install these dependencies using the following command:

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

Download the CMake Source

First, visit the GitHub releases page and find the link to the latest version of CMake.

After grabbing a fresh link, download the source code archive using the wget command:

wget https://github.com/Kitware/CMake/releases/download/v{version}/cmake-{version}-linux-x86_64.tar.gz

Note: Make sure to replace {version} with the correct version number.

Extract Downloaded CMake Source Archive

Extract the contents of the downloaded archive using the following command:

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

Now, navigate to the extracted directory:

cd /cmake-{your version}

Run the CMake Bootstrap Script

In this step, you will run the bootstrap script, which prepares the build system for compiling CMake. If you encounter any issues, ensure you have installed all the required dependencies mentioned earlier.

Run the bootstrap script with the following command:

./bootstrap

The bootstrap script may take a few minutes to complete.

Screenshot showing successful bootstrap completion for CMake installation on Fedora Linux.
First Step Success: Bootstrap Completion for CMake on Fedora Linux

Build and Compile CMake

Once the bootstrap script has finished, use the make command to build CMake:

make

The build process can take several minutes, so you might want to grab a coffee or take a short break while waiting.

Screenshot depicting the completed 'make' process for CMake, ready for installation on Fedora Linux.
Pre-Installation Stage: ‘Make’ Process Successfully Completed for CMake on Fedora Linux

Install CMake Binary

After the build process is complete, install CMake using the make install command:

sudo make install
Screenshot indicating successful compilation and installation of CMake on Fedora Linux.
Installation Complete: CMake Successfully Compiled and Installed on Fedora Linux

Verify CMake Installation via Source

After completing the installation, check the installed CMake version to ensure the correct installation:

cmake --version

Conclusion

In this guide, we explored a couple of straightforward paths to get CMake up and running on your Fedora Linux setup. You’ve got the choice of a quick and easy install from Fedora’s own stash, perfect for most folks, or rolling up your sleeves to compile from source if you’re after the newest bells and whistles. Just remember, if you go the source route, you’ll need to handle updates yourself. Either way, you’re now equipped to leverage CMake’s powerful features for your development endeavors.

Leave a Comment


Your Mastodon Instance
Share to...