How to Install CMake on AlmaLinux 9
You’ll learn how to get a modern CMake up and running on AlmaLinux 9 without chasing obscure repositories or wrestling with outdated binaries. A fresh install will let you build projects that rely on the latest CMake features, and it keeps your system clean.
Check Your Current CMake Version
Before doing anything, see whether a usable version is already present. Open a terminal and type
cmake --version
If the output shows something older than 3.20 or no result at all, proceed to install. (A developer on one of their CI runners reported that the stock “cmake” was missing entirely, which caused build failures.)
Installing the Latest Release via DNF
AlmaLinux 9 ships with a built‑in `dnf` package manager. The official repos provide CMake 3.25, but it may still be older than what your project needs. Installing from the base repo is quick:
sudo dnf install cmake
Why this matters: DNF handles dependencies for you and ensures that any libraries required by CMake are pulled in automatically.
Bringing in EPEL for a Fresh Build
If the version from the base repo falls short, enable the Extra Packages for Enterprise Linux (EPEL) repository. It contains a newer CMake build:
sudo dnf install epel-release sudo dnf update sudo dnf install cmake
Once again, DNF takes care of dependencies and updates your system to the newest EPEL package. The only downside: you add another external repo, but it’s a lightweight addition that only pulls in packages you ask for.
Compiling from Source if You Need the Absolute Cut‑Edge
When you need the bleeding‑edge features of CMake 3.30+ (for example, to use the new `CMAKE_CUDA_ARCHITECTURES` property), compile it yourself:
1. Install build tools and prerequisites
sudo dnf groupinstall "Development Tools" sudo dnf install curl
2. Download the source tarball from the official site
curl -LO https://github.com/Kitware/CMake/releases/download/v3.30.0/cmake-3.30.0.tar.gz tar xf cmake-3.30.0.tar.gz cd cmake-3.30.0
3. Configure, build, and install
./bootstrap --prefix=/usr/local make -j$(nproc) sudo make install
Why this matters: Building from source guarantees you’re running the exact version your project demands, sidestepping repo lag. The only trade‑off is extra time spent compiling.
Verifying the Install
After any installation path, confirm that the system uses the expected binary:
which cmake cmake --version
The `which` command should point to `/usr/local/bin/cmake` if you built from source, or `/usr/bin/cmake` for a DNF install. If the version number matches your target release, you’re good to go.
That’s it—no more mysterious “command not found” errors on AlmaLinux 9.