| Tested on | Ubuntu 26.04 LTS (Resolute Raccoon) |
|---|---|
| Package | cmake 4.2.3-2ubuntu2 (Ubuntu apt)Kitware apt: cmake 4.4.4-0kitware1ubuntu26.04.1Official binary: CMake 4.4.4 ( linux-x86_64) |
| Applies to | Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS (default apt CMake version differs by release) |
| Privilege | sudo or root for apt, Kitware repository setup, and system-wide binary installs |
| Scope | Install CMake on Ubuntu from apt (recommended), from Kitware's signed apt repository when you need a newer CMake than your release ships, or from official prebuilt Linux binaries for a pinned or portable tree; optional Snap, source build, and GUI packages; verify with cmake --version, type -a cmake, and a minimal C++ project; troubleshoot PATH conflicts and CMake 4 policy errors. Does not cover PyPI pip install cmake as a general system install path. |
| Related guides | apt command in Linux Check Ubuntu version Install Boost on Ubuntu Install OpenCV on Ubuntu Remove software on Ubuntu |
CMake reads each project's CMakeLists.txt configuration file, finds your compiler, and generates build instructions for a lower-level tool such as Make or Ninja, which then runs g++ or Clang. It does not replace a C or C++ compiler. Most modern C and C++ projects expect CMake on the build host—see install OpenCV on Ubuntu or install Boost on Ubuntu for larger examples after CMake is available.
On Ubuntu the default path is sudo apt install cmake. Ubuntu 26.04 already ships CMake 4.2.x in main; 24.04 and 22.04 stay on CMake 3.x, so projects that require CMake 4.x may need Kitware's apt repository, the Snap, or an official Linux binary on those LTS releases. This guide was tested on Ubuntu 26.04 with apt 4.2.3, Kitware apt 4.4.4, and the official 4.4.4 linux-x86_64 installer under /opt.
Quick answer
For most developers on a supported Ubuntu LTS:
sudo apt update
sudo apt install cmakeCheck whether that version satisfies your project's cmake_minimum_required(VERSION …) line in CMakeLists.txt. If apt is too old, add Kitware's apt repository and run sudo apt install cmake again, or install an official binary under /opt without replacing Ubuntu's package.
Before you begin
CMake is a build configuration tool, not a C or C++ compiler. On Ubuntu, install build-essential when you need g++ for the C++ test at the end of this guide.
A typical C++ workflow looks like this:
CMakeLists.txt
↓
CMake
↓
Make or Ninja
↓
g++ / Clang
↓
Program or libraryNear the top of CMakeLists.txt, projects often declare the oldest CMake they support:
cmake_minimum_required(VERSION 3.28)Compare that number with cmake --version before you replace Ubuntu's package with a newer CMake.
The install commands below run on the Ubuntu machine where you build your software. PATH is the ordered list of directories your shell searches when you type a command; if several cmake binaries exist, the first matching directory on PATH wins.
CMake versions on Ubuntu 26.04, 24.04, and 22.04
| Ubuntu | CMake from apt | What that means |
|---|---|---|
| 26.04 LTS | 4.2.3 | CMake 4.x is already in the archive—many projects build without a third-party repo |
| 24.04 LTS | 3.28.3 | Solid for most 3.x-era projects; some newer upstream trees may need Kitware apt or a binary |
| 22.04 LTS | 3.22.1 | Older policy defaults; more likely to hit cmake_minimum_required below what upstream expects |
| Upstream stable (reference) | 4.4.4 | Newer than any default apt version at the time of testing—use Kitware apt or official binaries when you need this exact line |
Run apt-cache policy cmake on your machine before choosing another install path. Confirm your release with check Ubuntu version when you are not sure which row applies.
Which CMake installation method should you use?
| Method | Use when |
|---|---|
| Ubuntu apt | Default for everyday development; matches distro packages and security updates |
| Kitware apt repository | You want a newer CMake but still manage it with apt upgrade |
Official .sh binary |
You need a specific version or an isolated tree (often under /opt/cmake-VERSION) |
| Snap (optional) | You accept Snap confinement and want current upstream builds without compiling |
| Source build (optional) | Custom patches, unsupported architecture, or development snapshots—not for ordinary "latest stable" installs |
| GUI packages (optional) | You want cmake-gui or ccmake from Ubuntu packages |
┌──────────────────────────────────────────┐
│ Need CMake on Ubuntu for a C/C++ app │
└────────────────────┬─────────────────────┘
│
┌───────────────┴────────────────┐
│ Does Ubuntu apt CMake satisfy │
│ cmake_minimum_required(VERSION)?│
└───────────────┬────────────────┘
yes │ no
▼ │ ▼
┌──────────┐ │ ┌─────────────────────┐
│ Ubuntu │ │ │ Want newer CMake │
│ apt │ │ │ through apt upgrade?│
└──────────┘ │ └──────────┬──────────┘
│ yes │ no
│ ▼ │ ▼
│ ┌──────────┐│ ┌──────────────┐
│ │ Kitware ││ │ Official │
│ │ apt repo ││ │ binary /opt │
│ └──────────┘│ └──────────────┘Pick one primary cmake on your PATH when you can. Common locations:
/usr/bin/cmake— Ubuntu apt or Kitware apt packages/snap/bin/cmake— Snap install/opt/cmake-VERSION/bin/cmake— isolated official binary (recommended for manual installs)/usr/local/bin/cmake— many source or.shinstalls with--prefix=/usr/local
/usr/local/bin often precedes /usr/bin, and Snap adds /snap/bin, so cmake --version can disagree with the package you thought you installed until you run type -a cmake.
Install CMake from Ubuntu apt
Ubuntu documents CMake as a normal development package installed with apt. This path is the one to try first.
Check the available CMake version
Refresh indexes and inspect the candidate before you install:
sudo apt updateThen read the candidate version apt would install. In apt-cache policy output, Candidate is the version APT would install or upgrade to right now:
apt-cache policy cmakeSample output on Ubuntu 26.04 (amd64):
cmake:
Installed: (none)
Candidate: 4.2.3-2ubuntu2
Version table:
4.2.3-2ubuntu2 500
500 http://archive.ubuntu.com/ubuntu resolute/main amd64 PackagesOn 24.04 you should see a 3.28.x candidate; on 22.04, 3.22.x. The candidate line is what sudo apt install cmake will place in /usr/bin/cmake.
Install CMake
Install the cmake package. It pulls in cmake-data automatically—you do not install cmake-data separately.
sudo apt install cmakeVerify the installation
Ask the shell which binary wins and print the version Kitware reports:
command -v cmakeList every cmake on your PATH when more than one install might exist:
type -a cmakePrint the version string from the binary that wins:
cmake --version/usr/bin/cmake
cmake is /usr/bin/cmake
cmake is /bin/cmake
cmake version 4.2.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).type -a is especially useful after you add Kitware apt, Snap, or a manual tree—multiple paths can coexist on disk.
Install a newer CMake from Kitware's apt repository
Kitware develops and maintains CMake. Kitware's apt repository is their signed Ubuntu package source—not a Launchpad PPA—and ships newer cmake packages than some LTS releases include in the main archive.
The repo documents 26.04 (resolute), 24.04 (noble), and 22.04 (jammy) repository lines. The page header still mentions older supported releases only, but the resolute instructions are present and worked on the Ubuntu 26.04 test host (apt offered 4.4.4 after the repo was added).
Use this path when Ubuntu's archive CMake is below your project's cmake_minimum_required but you still want sudo apt upgrade to manage CMake.
When the Kitware repository makes sense
Kitware apt is a good fit when:
- You are on 22.04 or 24.04 and need CMake 4.x or a newer 3.x than Ubuntu ships
- You are on 26.04 and want 4.4.x while staying on apt rather than a manual
/opttree - You prefer
.debintegration over Snap or a standalone tarball
Kitware asks that you not point CI jobs at this repository—use official release binaries for repeatable pipelines.
Add the Kitware repository
On a minimal image, install certificate and key tools first:
sudo apt-get updateInstall tools needed to fetch and verify the repository signing key:
sudo apt-get install ca-certificates gpg wgetIf kitware-archive-keyring is not already on the system, import the signing key once (fingerprint documented on apt.kitware.com):
test -f /usr/share/doc/kitware-archive-keyring/copyright ||
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null |
gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/nullAdd the repository line for your Ubuntu codename—only one of the following blocks applies:
Ubuntu 26.04 (resolute):
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ resolute main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/nullUbuntu 24.04 (noble):
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/nullUbuntu 22.04 (jammy):
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/nullUpdate indexes:
sudo apt-get updateIf you imported the key manually and kitware-archive-keyring was not installed before, remove the temporary key file so the package can own the keyring:
test -f /usr/share/doc/kitware-archive-keyring/copyright ||
sudo rm /usr/share/keyrings/kitware-archive-keyring.gpgInstall the keyring package so key rotation stays managed:
sudo apt-get install kitware-archive-keyringInstall and verify CMake from Kitware apt
Install CMake now that the Kitware repository is enabled:
sudo apt-get install cmakeCheck that apt now prefers Kitware's build:
apt-cache policy cmakecmake:
Installed: 4.4.4-0kitware1ubuntu26.04.1
Candidate: 4.4.4-0kitware1ubuntu26.04.1
Version table:
*** 4.4.4-0kitware1ubuntu26.04.1 500
500 https://apt.kitware.com/ubuntu resolute/main amd64 Packages
4.2.3-2ubuntu2 500
500 http://archive.ubuntu.com/ubuntu resolute/main amd64 PackagesConfirm the active binary:
cmake --versioncmake version 4.4.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).To return to Ubuntu's archive CMake later, remove the Kitware list and refresh indexes:
sudo rm /etc/apt/sources.list.d/kitware.listRefresh package indexes after the list file is gone:
sudo apt updateCompare the Installed line with Ubuntu's archive Candidate:
apt-cache policy cmakeIf the installed Kitware build is newer than Ubuntu's Candidate, APT will not downgrade automatically when you run sudo apt install cmake. Either install the Ubuntu package version explicitly (use the exact 4.2.3-2ubuntu2-style string shown under Ubuntu's entry in apt-cache policy), or purge the Kitware packages first and reinstall Ubuntu's cmake:
sudo apt purge cmake cmake-dataReinstall from the Ubuntu archive only:
sudo apt install cmakeInstall a specific CMake version from official binaries
Kitware publishes prebuilt Linux archives on the CMake download page for linux-x86_64 and linux-aarch64. This section uses the self-extracting .sh installer; the .tar.gz is the same file tree without the installer wrapper—unpack it under /opt if you prefer tar over sh.
If you need one specific CMake version that stays separate from Ubuntu's package, use a dedicated prefix such as /opt/cmake-4.4.4. /opt is commonly used for manually installed third-party software; one directory per version makes removal a single rm -rf without touching /usr/bin/cmake.
Check your CPU architecture
Map Ubuntu's architecture name to Kitware's binary name:
dpkg --print-architecture |
Kitware Linux binary |
|---|---|
amd64 |
linux-x86_64 |
arm64 |
linux-aarch64 |
dpkg --print-architectureamd64Replace linux-x86_64 in the URLs below with linux-aarch64 on ARM64 systems.
Install the official Linux binary
Download the version you need (example 4.4.4 on amd64):
cd /tmpDownload the self-extracting installer for your architecture:
wget https://github.com/Kitware/CMake/releases/download/v4.4.4/cmake-4.4.4-linux-x86_64.shMark the script executable:
chmod +x cmake-4.4.4-linux-x86_64.shCreate the target prefix, then run the installer non-interactively:
sudo mkdir -p /opt/cmake-4.4.4Run the installer non-interactively. --skip-license skips the license prompt; --exclude-subdir places the CMake tree directly inside the prefix instead of creating another versioned folder beneath it:
sudo sh cmake-4.4.4-linux-x86_64.sh --skip-license --exclude-subdir --prefix=/opt/cmake-4.4.4The installer prints Unpacking finished successfully when the tree is ready under /opt/cmake-4.4.4.
You can keep Ubuntu's apt cmake installed. /usr/local/bin and /opt/.../bin only take precedence after you extend PATH. If you want the manual tree to be the default in every new shell, append:
echo 'export PATH="/opt/cmake-4.4.4/bin:$PATH"' >> ~/.bashrcReload the shell or run export PATH="/opt/cmake-4.4.4/bin:$PATH" for the current session before testing.
Verify which CMake binary is active
Call the binary by full path first—this proves the unpack worked regardless of PATH:
/opt/cmake-4.4.4/bin/cmake --versioncmake version 4.4.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).After adjusting PATH, compare with the system default:
command -v cmakeCompare every candidate binary the shell knows about:
type -a cmakeIf command -v still shows /usr/bin/cmake while you intended to use /opt, your PATH order needs another look—not a failed install.
Optional: Install CMake with Snap
The cmake Snap is published by Canonical and maintained separately from the upstream CMake project. Install it when you want a current upstream build without adding Kitware apt or unpacking binaries yourself:
sudo snap install cmake --classic--classic gives the Snap broader filesystem access than a strictly confined Snap, which a build tool needs to work with arbitrary source and build directories.
Check the Snap's view of the version:
snap run cmake --versionSnap places cmake under /snap/bin. If both apt and Snap are installed, type -a cmake may list /snap/bin/cmake before or after /usr/bin/cmake depending on /etc/environment and your shell profile.
Optional: Build CMake from source
Compiling CMake is rarely the fastest way to get the latest stable release—Kitware apt and official binaries cover that case. Source still matters for custom patches, unsupported platforms, or pre-release trees.
Install toolchain dependencies:
sudo apt updatePull in a compiler and OpenSSL headers for the bootstrap step:
sudo apt install build-essential libssl-devDownload and build (example 4.4.4):
cd /tmpFetch the source archive from GitHub releases:
wget https://github.com/Kitware/CMake/releases/download/v4.4.4/cmake-4.4.4.tar.gzExtract the tarball:
tar -xzf cmake-4.4.4.tar.gzMove into the source tree:
cd cmake-4.4.4Configure the build with your install prefix:
./bootstrap --prefix=/opt/cmake-4.4.4-srcCompile CMake itself (this step takes several minutes):
make -j"$(nproc)"-j"$(nproc)" lets the build use all CPU cores; lower the number if you need to cap load on a shared machine.
Install as root into the chosen prefix:
sudo make installAdd /opt/cmake-4.4.4-src/bin to PATH the same way as the official binary section. To remove a source install, delete that prefix directory—or use install_manifest.txt from the build tree if you need an exact file list.
Optional: Install CMake GUI tools
Ubuntu ships optional front ends alongside the cmake package:
Qt GUI (cmake-gui):
sudo apt install cmake-qt-guiTerminal curses UI (ccmake):
sudo apt install cmake-curses-guiOfficial binary trees under /opt also include cmake-gui and ccmake in the same bin directory as the CLI.
Test CMake with a minimal C++ project
CMake configures projects out of source: -S . points at the directory that contains CMakeLists.txt, and -B build puts generated files in a separate build/ folder. The test below needs a C++ compiler—install build-essential if g++ is missing.
Configure an out-of-source build
Create a tiny project under /tmp:
mkdir -p /tmp/cmake-helloUse that directory for the source and build trees:
cd /tmp/cmake-helloWrite CMakeLists.txt with a floor that matches Ubuntu 22.04's apt CMake (3.22):
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.22)
project(hello LANGUAGES CXX)
add_executable(hello main.cpp)
EOFAdd a valid C++ source file:
cat > main.cpp <<'EOF'
#include <iostream>
int main() {
std::cout << "CMake build OK\n";
return 0;
}
EOFGenerate build files in build/. CMake picks a generator (for example Unix Makefiles or Ninja) that tells Make or Ninja how to compile the project:
cmake -S . -B buildCMake should finish with Generating done and no errors about the minimum version.
Build and run the program
Compile the target:
cmake --build buildRun the binary:
./build/helloCMake build OKIf configure fails with a version error, compare cmake --version against cmake_minimum_required in the project you are building—not only this hello-world stub.
Update CMake
Ubuntu apt: run sudo apt update and sudo apt install --only-upgrade cmake when a security or point release lands in the archive.
Kitware apt: with kitware.list enabled, the same sudo apt install --only-upgrade cmake pulls newer Kitware builds when they publish.
Snap: sudo snap refresh cmake.
Manual /opt binary: download a newer .sh, install to a new prefix (for example /opt/cmake-4.5.0), update your PATH line, and remove the old prefix when you no longer need it.
Uninstall CMake
Ubuntu packages: remove only what you installed. If you added the CLI plus both optional GUI packages, for example:
sudo apt purge cmake cmake-qt-gui cmake-curses-guiPreview suggested removals:
sudo apt-get -s autoremoveRun sudo apt autoremove only after you agree with the simulated list.
Kitware apt: remove /etc/apt/sources.list.d/kitware.list, run sudo apt update, and check apt-cache policy cmake. APT does not downgrade a newer Kitware cmake automatically—use the explicit downgrade or purge-and-reinstall steps in the Kitware section above if you want Ubuntu's archive build back.
Snap:
sudo snap remove cmakeOfficial or source tree under /opt: remove only the prefix you created—for example sudo rm -rf /opt/cmake-4.4.4—and delete any PATH lines you added in ~/.bashrc. Avoid broad sudo rm -rf /usr/local/share/cmake-* unless you are certain no other software shares that layout.
For general package cleanup patterns, see remove software on Ubuntu.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
cmake: command not found |
CMake not installed, or bin not on PATH |
sudo apt install cmake, or add /opt/cmake-VERSION/bin to PATH |
g++: command not found during cmake --build |
Compiler toolchain missing | sudo apt install build-essential |
| Project requires a newer CMake | Ubuntu apt below cmake_minimum_required |
Add Kitware apt, use an official binary, or optional Snap—not an old PPA |
cmake --version shows the wrong install |
Multiple cmake binaries on PATH |
Run type -a cmake; adjust PATH or remove the install you do not want |
CMAKE_ROOT or module errors |
Mixed files from apt and a manual install | Pick one primary install; purge or remove the other tree's cmake and module directories |
| Compiler not found during configure | No build-essential / no CXX compiler |
sudo apt install build-essential |
| Old project fails after CMake 4 upgrade | CMake 4 removed compatibility below policy 3.5; very old cmake_minimum_required values fail |
If you maintain the project, raise cmake_minimum_required and policies after testing; if not, check upstream supported CMake versions before editing build files or downgrading CMake |
cmake3 vs cmake confusion |
Legacy docs for Ubuntu 14.04 | On current Ubuntu install package cmake only |
| Snap cannot see host compilers | Strict confinement without classic | sudo snap install cmake --classic |
Summary
Install CMake on Ubuntu with sudo apt install cmake whenever the version in apt-cache policy cmake meets your project's cmake_minimum_required line. Ubuntu 26.04 already provides CMake 4.2.x in main; 24.04 and 22.04 remain on 3.28.x and 3.22.x, so newer upstream trees may push you toward Kitware's apt repository or an official binary.
When apt is too old but you still want package management, add Kitware's signed repository for your codename (resolute, noble, or jammy), install kitware-archive-keyring, then upgrade cmake—the test host moved from 4.2.3 to 4.4.4 that way. If you need one specific version separate from Ubuntu's package, unpack the linux-x86_64 or linux-aarch64 .sh installer under /opt/cmake-VERSION and put that bin directory on PATH.
After any method, run command -v cmake, type -a cmake, and cmake --version, then configure a minimal out-of-source C++ project with cmake -S . -B build. Keeping apt, Snap, /usr/local, and /opt installs straight on PATH prevents the common case where a newer install is on disk but the shell still runs an older /usr/bin/cmake.
References
- Installing CMake — official overview
- CMake download — Linux
.sh,.tar.gz, and source archives - Kitware APT Repository — signed Ubuntu repositories
- cmake on Snapcraft — Snap distribution notes
Frequently Asked Questions
Which CMake version does Ubuntu 26.04 include?
Ubuntu 26.04 ships CMake 4.2.3 in main for amd64 at the time of testing. Run apt-cache policy cmake on your system to confirm the candidate before you install.
Which CMake version does Ubuntu 24.04 include?
Ubuntu 24.04 LTS provides CMake 3.28.3 from the archive. Use Kitware apt or an official binary when a project requires CMake 4.x or a newer 3.x than 3.28.
Which CMake version does Ubuntu 22.04 include?
Ubuntu 22.04 LTS ships CMake 3.22.1 from the archive. That satisfies many older projects but is the most likely LTS release to fall below a strict cmake_minimum_required from current upstream code.
How do I install the latest CMake on Ubuntu?
Add Kitware's apt repository for your Ubuntu codename and run sudo apt install cmake, or install the current stable Linux binary from cmake.org/download. On 26.04, Ubuntu apt may already be new enough that you only need Kitware apt or a binary for a specific newer patch release such as 4.4.4.
Should I use Ubuntu apt or Kitware apt?
Use Ubuntu apt when the archive version satisfies your project. Use Kitware apt when you need a newer CMake but still want apt upgrade to manage it. Do not use both interchangeably without checking apt-cache policy cmake and type -a cmake.
Can multiple CMake versions be installed?
Yes. apt installs /usr/bin/cmake, Snap uses /snap/bin/cmake, and manual installs use /opt/.../bin or /usr/local/bin. Only the first match on PATH runs when you type cmake. Use type -a cmake to see every candidate.
Do I need to remove Ubuntu cmake before installing the official .sh binary?
No. You can keep apt CMake and call /opt/cmake-VERSION/bin/cmake directly, or prepend that bin directory to PATH. Remove apt CMake only when you want a single unambiguous default on PATH.
How do I install CMake GUI on Ubuntu?
Install cmake-qt-gui for the Qt interface or cmake-curses-gui for ccmake. Official binary trees include the same GUI binaries in their bin directory.

