Many C and C++ projects fail before compilation starts when CMake is missing. The configure step uses CMake to detect compilers, generate build files, and locate libraries. Install CMake on Fedora with the distro package for the fastest maintained path; Fedora 44 already provides CMake 4, while Fedora 43 remains on the 3.31 series.
Use the Fedora package unless a project explicitly requires a newer Kitware release. The upstream binary method covers that case without compiling CMake itself, but it uses an article-owned /opt/cmake-upstream prefix and a local update helper.
Install CMake on Fedora
Choose a CMake Method on Fedora
The package name for the normal Fedora install is cmake, so sudo dnf install cmake is the correct command. The upstream method is only useful when your project needs a newer CMake release than your Fedora branch currently ships.
| Method | Source | Version Scope | Updates | Best Fit |
|---|---|---|---|---|
| Fedora package | Fedora package repositories | Fedora 44 currently ships 4.3.x; Fedora 43 ships 3.31.x | Managed by dnf upgrade | Most development systems and CI runners |
| Kitware upstream binary | CMake GitHub releases | Latest non-prerelease Kitware build for x86_64 or aarch64 | Run sudo update-cmake-upstream | Projects that require a newer upstream point release |
Building CMake from source is a custom-maintainer path for patches or nonstandard compile flags. For most Fedora users who only need a newer release, Kitware’s prebuilt Linux archive is faster to verify, install, update, and remove.
Refresh Fedora Packages Before Installing CMake
Refresh package metadata and apply pending updates before installing development tools. Review the transaction before confirming, especially on shared workstations or build servers.
sudo dnf upgrade --refresh
Install CMake with DNF
Install CMake from Fedora’s normal repositories:
sudo dnf install cmake
DNF installs the main cmake package plus required support packages such as cmake-data, cmake-filesystem, jsoncpp, and rhash when they are not already present.
Install Build Tools for C++ Projects
CMake generates build files, but it does not replace a compiler. Install the C++ compiler and Make if you plan to build local C++ projects or follow the test project later in this article:
sudo dnf install gcc-c++ make
For a broader development workstation, Fedora’s Development Tools group also includes debuggers and related build utilities. Use the DNF5 group commands on Fedora reference if you want to inspect or install package groups instead of individual packages.
Verify CMake on Fedora
Confirm the command is available:
cmake --version
Fedora 44 currently returns CMake 4 from the Fedora package:
cmake version 4.3.0 CMake suite maintained and supported by Kitware (kitware.com/cmake).
Check the exact RPM revision when a project or bug report asks which Fedora build you are using:
rpm -q cmake
Fedora 44 currently reports:
cmake-4.3.0-1.fc44.x86_64
Install Latest Upstream CMake on Fedora
Use Kitware’s upstream binary only when the Fedora package is too old for the project you need to build. This method works on x86_64 and aarch64 Fedora systems because Kitware publishes Linux archives for both architectures. Kitware also publishes .sh installers, but the .tar.gz archive keeps removal easier to audit because every extracted file stays under one prefix.
Install Upstream Helper Requirements
Install the small tools used by the update helper to resolve the latest release, download the archive, extract it, and verify the checksum:
sudo dnf install curl python3 tar gzip
The helper uses the curl command in Linux with -fsSLO: -f fails on HTTP errors, -s hides progress noise, -S still shows errors, -L follows redirects, and -O saves the remote filename locally.
Create the Upstream CMake Update Helper
Create a reusable helper that detects the latest non-prerelease CMake tag from GitHub, maps your Fedora architecture to Kitware’s archive name, verifies the SHA-256 checksum, replaces the article-owned prefix, and refreshes the command symlinks. Reuse the same helper later for updates.
sudo tee /usr/local/bin/update-cmake-upstream >/dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
if [ "$(id -u)" -ne 0 ]; then
echo "Run this helper with sudo: sudo update-cmake-upstream" >&2
exit 1
fi
prefix=/opt/cmake-upstream
bin_dir=/usr/local/bin
release_api=https://api.github.com/repos/Kitware/CMake/releases/latest
cmake_ver=$(curl -fsSL "$release_api" | python3 -c 'import json, sys; print(json.load(sys.stdin)["tag_name"].lstrip("v"))')
case "$(uname -m)" in
x86_64) cmake_arch=linux-x86_64 ;;
aarch64|arm64) cmake_arch=linux-aarch64 ;;
*) printf 'Unsupported architecture: %s\n' "$(uname -m)" >&2; exit 1 ;;
esac
archive="cmake-${cmake_ver}-${cmake_arch}.tar.gz"
checksum_file="cmake-${cmake_ver}-SHA-256.txt"
base_url="https://github.com/Kitware/CMake/releases/download/v${cmake_ver}"
guard_links() {
for tool in cmake ctest cpack; do
link="${bin_dir}/${tool}"
expected="${prefix}/bin/${tool}"
if [ -L "$link" ]; then
current_target=$(readlink "$link")
if [ "$current_target" != "$expected" ]; then
printf 'Refusing to replace %s because it points to %s.\n' "$link" "$current_target" >&2
exit 1
fi
elif [ -e "$link" ]; then
printf 'Refusing to overwrite %s because it is not a symlink.\n' "$link" >&2
exit 1
fi
done
}
refresh_links() {
for tool in cmake ctest cpack; do
ln -sfn "${prefix}/bin/${tool}" "${bin_dir}/${tool}"
done
}
guard_links
current_ver=""
if [ -x "${prefix}/bin/cmake" ]; then
current_ver=$("${prefix}/bin/cmake" --version | awk '/^cmake version/ {print $3; exit}')
fi
if [ "$current_ver" = "$cmake_ver" ]; then
refresh_links
printf 'CMake %s is already installed.\n' "$cmake_ver"
exit 0
fi
work_dir=$(mktemp -d)
old_prefix=""
restore_old_prefix() {
if [ -n "$old_prefix" ] && [ -e "$old_prefix" ] && [ ! -e "$prefix" ]; then
mv "$old_prefix" "$prefix"
fi
}
cleanup() {
status=$?
restore_old_prefix
rm -rf "$work_dir"
exit "$status"
}
trap cleanup EXIT
cd "$work_dir"
curl -fsSLO "${base_url}/${archive}"
curl -fsSLO "${base_url}/${checksum_file}"
grep " ${archive}$" "$checksum_file" | sha256sum -c -
install_dir="${work_dir}/cmake-upstream"
mkdir -p "$install_dir"
tar -xzf "$archive" --strip-components=1 -C "$install_dir"
"${install_dir}/bin/cmake" --version >/dev/null
if [ -e "$prefix" ] && [ ! -d "$prefix" ]; then
printf 'Refusing to replace %s because it is not a directory.\n' "$prefix" >&2
exit 1
fi
if [ -d "$prefix" ]; then
old_prefix="${prefix}.previous.$(date +%s)"
mv "$prefix" "$old_prefix"
fi
mv "$install_dir" "$prefix"
refresh_links
if [ -n "$old_prefix" ]; then
rm -rf "$old_prefix"
old_prefix=""
fi
"${prefix}/bin/cmake" --version
EOF
Make the helper executable:
sudo chmod 755 /usr/local/bin/update-cmake-upstream
Confirm the helper is available from the shell:
command -v update-cmake-upstream
/usr/local/bin/update-cmake-upstream
Install Upstream CMake With the Helper
The helper replaces the
/opt/cmake-upstreamdirectory used by this method and refreshes its/usr/local/binsymlinks. Back up anything you manually added under that directory before running it.
Run the helper to download the verified .tar.gz archive, extract it into the dedicated prefix, and activate the upstream commands. The guide to open gz and tgz files in Linux explains the tar -xzf option pattern in more detail.
sudo update-cmake-upstream
Example output from the current x86_64 release looks like this; your version number may differ:
cmake-4.3.2-linux-x86_64.tar.gz: OK cmake version 4.3.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
Verify Upstream CMake on Fedora
Check the upstream command directly from /usr/local/bin:
/usr/local/bin/cmake --version
A successful upstream install returns a CMake banner like this; your version number may differ:
cmake version 4.3.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
Test CMake with a Small C++ Project
A small build proves that CMake, the compiler, and Make are working together. Create a clean test directory and write a minimal C++ source file:
mkdir -p ~/cmake-test
cd ~/cmake-test
cat > main.cpp <<'EOF'
#include <iostream>
int main() {
std::cout << "CMake is working!" << std::endl;
return 0;
}
EOF
Create a basic CMakeLists.txt file for the project:
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.10)
project(HelloCMake LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
add_executable(hello main.cpp)
EOF
Configure and build the project. The explicit Unix Makefiles generator keeps the example tied to the make package installed earlier:
cmake -S . -B build -G "Unix Makefiles"
cmake --build build
./build/hello
The final command should print:
CMake is working!
Remove the test project when you no longer need it:
cd ~
rm -rf ~/cmake-test
Update CMake on Fedora
Update the Fedora CMake Package
The Fedora package updates with normal system maintenance. Use a targeted upgrade when you only want to check CMake and its dependencies:
sudo dnf upgrade cmake
After the upgrade, recheck the version:
cmake --version
Update Upstream CMake
For the Kitware upstream method, rerun the helper. It checks the latest release, verifies the matching archive, replaces /opt/cmake-upstream when a newer version is available, and exits cleanly when the current version is already installed.
sudo update-cmake-upstream
If the installed upstream release is already current, the helper returns a short status line like this:
CMake 4.3.2 is already installed.
If Kitware has published a newer release, the helper prints the checksum result and the new cmake --version banner instead.
Remove CMake from Fedora
Remove the Fedora CMake Package
Remove the Fedora-managed package with DNF:
sudo dnf remove cmake
Verify the package is no longer installed:
rpm -q cmake || true
A removed package returns:
package cmake is not installed
If you installed gcc-c++ and make only for the test project, remove them separately after confirming no other local builds need them.
sudo dnf remove gcc-c++ make
Remove Upstream CMake
The next commands permanently delete the upstream CMake prefix and remove only symlinks that still point into that prefix. They do not remove the Fedora package under
/usr/binif you installed it separately.
for tool in cmake ctest cpack; do
link="/usr/local/bin/$tool"
target="/opt/cmake-upstream/bin/$tool"
if [ -L "$link" ] && [ "$(readlink -f "$link")" = "$target" ]; then
sudo rm -f "$link"
fi
done
sudo rm -rf /opt/cmake-upstream
sudo rm -f /usr/local/bin/update-cmake-upstream
hash -r
command -v update-cmake-upstream || echo "update-cmake-upstream command not found"
command -v cmake || echo "cmake command not found"
The helper removal check should print update-cmake-upstream command not found. If the Fedora package remains installed, the final CMake check should return /usr/bin/cmake. If no CMake method remains installed, it prints cmake command not found.
Troubleshoot CMake on Fedora
CMake Command Not Found
If the shell cannot find CMake, either the package is missing or the current shell still has an old command path cached.
bash: cmake: command not found
Install the Fedora package, then clear the shell command cache:
sudo dnf install cmake
hash -r
cmake --version
CMake Cannot Find a C++ Compiler
CMake can generate build files only after it finds the compiler your project language requires. A missing C++ compiler commonly appears during project(... LANGUAGES CXX) or the first configure step.
Check whether Fedora can find the C++ compiler command:
command -v c++ || echo "c++ compiler missing"
If the compiler is missing, install the C++ toolchain and rerun CMake from a clean build directory:
sudo dnf install gcc-c++ make
rm -rf build
cmake -S . -B build -G "Unix Makefiles"
Older Projects Fail with CMake 4 on Fedora 44
Fedora 44 moved CMake to the 4.x series, and Fedora’s CMake 4 change note calls out one common compatibility break: projects that set only a very old cmake_minimum_required lower bound can fail because CMake 4 removed pre-3.5 old-policy behavior.
The durable fix is to update the project’s cmake_minimum_required line or use a project release that already supports CMake 4. For a temporary local build check, pass the policy minimum explicitly:
cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5
Treat that option as a short-term compatibility probe, not a patch to ship downstream. If the project is still maintained, report the failure upstream so its build files can declare a modern policy range.
Use CMake Documentation After Installation
The official CMake documentation is the best next reference for commands such as cmake --build, presets, toolchain files, package discovery with find_package(), CTest, and CPack. Fedora’s package supplies the same core command-line workflow, while the upstream binary can expose newer documentation features sooner.
Conclusion
CMake is ready for Fedora builds, with the distro package handling routine updates and the upstream Kitware binary available when a project needs a newer release. For the next step, install Git on Fedora for source control. If you want an editor beside the terminal, install Visual Studio Code on Fedora or install Code::Blocks on Fedora.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>