CMake is the cross-platform build-system generator behind most modern C and C++ projects. It reads CMakeLists.txt files, detects compilers, and emits Makefiles or Ninja build files so you can run cmake --build instead of hand-writing compile rules. On Ubuntu you can install CMake from apt (simplest), Snap (often newer), official Kitware binaries, the Kitware apt repository, or a source build when you need a specific release.
This guide shows how to install CMake on Ubuntu, check which version your repositories offer, avoid the PATH mistakes that leave cmake “not found” after a manual download, and verify the install with a tiny out-of-source project. Commands below were run on Ubuntu 25.04; paths and package versions match current amd64 releases.
Tested on: Ubuntu 25.04 (Plucky Puffin); kernel 6.14.0-37-generic; amd64.
apt, Snap, /usr/local, or /opt). Mixing apt cmake with a manual /usr/local/bin/cmake symlink often makes which cmake and cmake --version disagree. Remove the old package before switching (sudo apt purge cmake).
Quick command summary
| Task | Command |
|---|---|
| Check apt candidate | apt-cache policy cmake |
| Install from Ubuntu repos | sudo apt update && sudo apt install -y cmake |
| Install via Snap | sudo snap install cmake --classic |
Official .sh to /usr/local |
sudo sh cmake-*-linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local |
Official .tar.gz under /opt |
sudo tar -xzf cmake-*-linux-x86_64.tar.gz -C /opt then extend PATH |
| Out-of-source configure | cmake -S . -B build |
| Build | cmake --build build |
| Optional GUI | sudo apt install -y cmake-qt-gui |
| Remove apt package | sudo apt purge -y cmake |
Prerequisites
- Ubuntu 22.04 LTS, 24.04 LTS, or newer (25.04 tested here) on x86_64 for the binary download filenames below.
- sudo for system-wide installs.
- build-essential (compiler toolchain) when you plan to compile CMake from source or build C++ projects after install—not required for
apt install cmakealone. - Outbound HTTPS to
archive.ubuntu.com,cmake.org, orgithub.comfor binary and source downloads.
Choose an install method
| Method | Best for | Typical version (2026) |
|---|---|---|
apt install cmake |
Everyday development on Ubuntu | 3.22–3.31 depending on LTS (3.31.6 on 25.04) |
Snap (cmake) |
Newer upstream without compiling | Tracks Snap Store releases (4.x) |
Official .sh installer |
Specific Kitware build at /usr/local |
Latest from cmake.org/download |
Official .tar.gz |
Portable tree under /opt without touching /usr/local |
Same as .sh, no installer prompts |
| Kitware apt repo | apt workflow but newer than distro default | Kitware-maintained packages |
| Source build | Bleeding-edge or custom prefixes | Whatever you compile |
On Ubuntu 14.04/16.04, older guides suggested PPAs such as ppa:george-edison55/cmake-3.x or a separate cmake3 package. Modern Ubuntu ships cmake in main/universe with a current 3.x release—start with apt unless your CMakeLists.txt enforces a higher cmake_minimum_required.
Step 1: Install CMake from apt (recommended)
Refresh indexes and inspect the candidate before installing:
sudo apt update
apt-cache policy cmakeExample on Ubuntu 25.04:
cmake:
Installed: (none)
Candidate: 3.31.6-1ubuntu1
Version table:
3.31.6-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu plucky/main amd64 PackagesInstall with apt:
sudo apt install -y cmakeThe cmake package depends on cmake-data; you do not need a separate sudo apt install cmake-data step.
Verify:
cmake --version
which cmake
dpkg -l cmakecmake version 3.31.6
CMake suite maintained and supported by Kitware (kitware.com/cmake).
/usr/bin/cmake
ii cmake 3.31.6-1ubuntu1 amd64 cross-platform, open-source make systemWhen Ubuntu’s candidate is too old for your project, compare the required version in cmake_minimum_required(VERSION …) and move to Snap, Kitware binaries, or the Kitware apt repository.
Step 2: Install CMake from Snap
Canonical documents Snap installs at snapcraft.io/install/cmake/ubuntu. The cmake snap is published by Crascit (a CMake co-maintainer), not Kitware directly, but it tracks current upstream releases.
sudo snap install cmake --classicThe --classic confinement flag is required so the build tool can read arbitrary project paths on disk.
Check the binary Snap exposes:
snap run cmake --version
which cmake # often /snap/bin/cmake when Snap’s path precedes /usr/binOn a host without Snap, apt install cmake already suggests:
sudo snap install cmake # version 4.3.4, or
sudo apt install cmake # version 3.31.6-1ubuntu1Use Snap when you need CMake 4.x features while staying on an LTS release whose apt candidate is still 3.22–3.28. Remove the apt package first if both would provide /usr/bin/cmake.
Step 3: Install from the official .sh binary
Kitware publishes self-extracting cmake-VERSION-linux-x86_64.sh files on the download page. This matches the non-interactive pattern from Stack Overflow: specify where CMake is installed.
Remove apt CMake so modules and CMAKE_ROOT stay consistent:
sudo apt purge -y cmake
sudo apt autoremove -yDownload a current release (example uses 4.3.4; pick the version your project needs):
cd /tmp
wget https://github.com/Kitware/CMake/releases/download/v4.3.4/cmake-4.3.4-linux-x86_64.sh
chmod +x cmake-4.3.4-linux-x86_64.shInstall into /usr/local without nested subdirectories or license prompts:
sudo sh cmake-4.3.4-linux-x86_64.sh \
--skip-license \
--exclude-subdir \
--prefix=/usr/localConfirm:
cmake --version
which cmakecmake version 4.3.4
/usr/local/bin/cmake/usr/local/bin is already on the default Ubuntu PATH, so you should not need to edit /etc/environment when you use --prefix=/usr/local as above.
Step 4: Install from the official .tar.gz binary
The .tar.gz distribution is a pre-built tree—the same layout the .sh installer extracts. Guides such as CGold CMake installation unpack it anywhere and extend PATH.
cd /tmp
wget https://github.com/Kitware/CMake/releases/download/v4.3.4/cmake-4.3.4-linux-x86_64.tar.gz
sudo tar -xzf cmake-4.3.4-linux-x86_64.tar.gz -C /optAdd the bin directory for your session:
export PATH="/opt/cmake-4.3.4-linux-x86_64/bin:$PATH"
cmake --versionPersist the line in ~/.bashrc (or /etc/profile.d/cmake.sh for all users) when you want this layout permanently:
echo 'export PATH="/opt/cmake-4.3.4-linux-x86_64/bin:$PATH"' >> ~/.bashrcThis method keeps Kitware’s files isolated under /opt and avoids overwriting /usr/bin/cmake from apt.
Step 5: Kitware apt repository (optional)
When you prefer deb packages but need a newer CMake than your Ubuntu release ships, Kitware maintains apt.kitware.com with signed repositories per distro codename. Follow their current instructions for adding the keyring and deb line, then:
sudo apt update
sudo apt install cmakeThis replaces the Ubuntu archive cmake candidate with Kitware’s build while staying on the apt upgrade path.
Step 6: Build CMake from source
Compile from source when you need a custom prefix, unreleased patches, or no pre-built binary for your platform. The workflow matches historical Ask Ubuntu and source-build notes—updated for current tarballs.
Install build dependencies (install OpenSSL on Ubuntu for libssl-dev):
sudo apt update
sudo apt install -y build-essential libssl-devDownload and bootstrap (example 4.3.4 source):
cd /tmp
wget https://github.com/Kitware/CMake/releases/download/v4.3.4/cmake-4.3.4.tar.gz
tar -xzf cmake-4.3.4.tar.gz
cd cmake-4.3.4
./bootstrap
make -j"$(nproc)"
sudo make installDefault make install places cmake in /usr/local/bin. Re-open your shell or run hash -r before testing.
For a tracked .deb, some admins use checkinstall instead of make install; plain make install is enough on a single-user dev machine.
Optional: CMake GUI (cmake-gui)
Desktop users who want the graphical configurator can install the Qt front-end from Ubuntu:
sudo apt install -y cmake-qt-gui
cmake-gui --versionOfficial .tar.gz / .sh bundles also ship cmake-gui in the same bin directory as the CLI.
Verify: minimal out-of-source project
After any install method, confirm CMake can configure and compile a trivial C++ target. Prefer out-of-source builds (cmake -S / cmake -B) over cmake . in the source tree.
mkdir -p /tmp/cmake-hello && cd /tmp/cmake-hello
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.10)
project(hello LANGUAGES CXX)
add_executable(hello main.cpp)
EOF
cat > main.cpp <<'EOF'
#include <iostream>
int main { std::cout << "CMake build OK\n"; }
EOF
cmake -S . -B build
cmake --build build
./build/helloExample configure/build output on Ubuntu 25.04 with apt CMake:
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Configuring done (2.9s)
-- Generating done (0.0s)
-- Build files have been written to: /tmp/cmake-hello/build
[ 50%] Building CXX object CMakeFiles/hello.dir/main.cpp.o
[100%] Linking CXX executable hello
[100%] Built target hello
CMake build OKUninstall
APT:
sudo apt purge -y cmake cmake-qt-gui
sudo apt autoremove -ySnap:
sudo snap remove cmakeManual /usr/local or /opt install:
sudo rm -f /usr/local/bin/cmake /usr/local/bin/ccmake /usr/local/bin/cmake-gui /usr/local/bin/ctest
sudo rm -rf /usr/local/share/cmake-*
sudo rm -rf /opt/cmake-*-linux-x86_64
# Remove any PATH lines you added to ~/.bashrcTroubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
cmake: command not found after .sh download |
Extracted to $HOME without --prefix |
Re-run installer with --prefix=/usr/local --exclude-subdir --skip-license, or add bin to PATH |
cmake --version shows old apt build |
/usr/bin before /usr/local on PATH |
which cmake; purge apt cmake or reorder PATH |
CMAKE_ROOT / module errors after upgrade |
Mixed apt + manual files | sudo apt purge cmake; remove /usr/local/share/cmake-*; reinstall one method |
Project fails cmake_minimum_required |
Ubuntu apt too old | Use Snap, Kitware binary, Kitware apt repo, or source build |
cmake3 vs cmake confusion |
Legacy 14.04 docs | On current Ubuntu install package cmake; cmake3 was transitional |
PPA george-edison55/cmake-3.x missing |
Abandoned PPA | Use apt, Snap, or official Kitware packages instead |
| Snap CMake cannot see host compilers | Strict confinement | Install with --classic as documented on Snapcraft |
References
- Installing CMake — official overview
- CMake download —
.sh,.tar.gz, and source archives - Kitware apt repository — newer debs on Ubuntu
- Install CMake on Ubuntu (Snapcraft) —
sudo snap install cmake --classic - Ask Ubuntu: How to install cmake 3.2 on Ubuntu — historical PPA/source context (prefer modern apt today)
- CGold: CMake installation on Ubuntu — apt and tarball
PATHpattern - Stack Overflow: specify CMake install location —
.sh--prefixflags - On-site: apt command, wget command
Summary
The fastest way to install CMake on Ubuntu is sudo apt install cmake: it pulls cmake-data, lands in /usr/bin/cmake, and on Ubuntu 25.04 provides 3.31.6. When projects require CMake 4.x or a specific Kitware release, use the Snap, the official .sh installer with --prefix=/usr/local --exclude-subdir --skip-license, a .tar.gz under /opt, the Kitware apt repository, or a source build.
Always verify with cmake --version, which cmake, and a small cmake -S . -B build project. Avoid stacking apt and manual installs, and skip obsolete cmake3/PPA workflows on current LTS releases unless you are maintaining legacy systems.

