To install CMake on Ubuntu, developers have four proven paths: the default APT repository for stable releases, Kitware’s official repository for newer versions with automatic updates, Snap (Canonical’s self-contained package format) for containerized installations, or source compilation for cutting-edge features. CMake functions as a build system generator rather than a build system itself, producing project files for Make, Ninja, Visual Studio, and other backends from a single portable configuration. This approach unifies cross-platform C and C++ builds across desktop, mobile, and embedded targets without maintaining separate build scripts for each toolchain.
This guide covers all installation methods with complete verification steps, helping you choose the approach that matches your development workflow and version requirements.
Choose Your CMake Installation Method
Ubuntu offers multiple paths to install CMake, each suited to different development needs. Choose based on your version requirements, maintenance preferences, and system constraints. The default APT repository (Ubuntu’s package manager, similar to Windows Update) delivers stable, well-tested releases that integrate seamlessly with Ubuntu’s update mechanism, making it the recommended starting point for most users. However, if you need cutting-edge features or want to avoid system package dependencies, alternative methods provide viable options.
The APT repository provides tested stable releases that integrate cleanly with system updates, while source compilation delivers the latest upstream features at the cost of manual maintenance. Alternatively, Kitware maintains an official APT repository with newer releases, and Snap packages offer containerized installations when system-wide integration isn’t required.
| Method | Version/Channel | Maintenance | Best For |
|---|---|---|---|
| APT Repository (Default) | Stable (3.22-3.28 typically) | Automatic via apt upgrade | Production environments, CI/CD pipelines, most development work |
| Source Compilation | Latest upstream (3.30+) | Manual rebuild for updates | Cutting-edge features, custom build options, testing new releases |
| Kitware APT Repository | Recent stable (3.29+) | Automatic via apt upgrade | Newer versions without compilation overhead |
| Snap Package | Latest stable | Automatic snap refresh | Isolated environments, non-root installations |
Most users should start with the default APT repository since it balances stability, maintenance convenience, and compatibility with Ubuntu’s ecosystem. The version lag rarely affects typical build workflows, and system updates handle security patches automatically. Source compilation makes sense when you specifically need features introduced after your repository version or want to customize build flags, but expect to rebuild manually whenever security updates or new releases appear.
Installing CMake on Ubuntu
Before proceeding with any installation method, update your package lists to ensure access to the latest versions. Run the following command to refresh repositories and apply pending updates:
sudo apt update && sudo apt upgrade
Method 1: Install CMake via Ubuntu Default Repository
Verify Current CMake Installation
Minimal Ubuntu images sometimes ship with CMake already installed. Verify the current status before installing anything new:
cmake --version
If a version number appears, you can skip to the testing section. Otherwise, continue with the package installation below.
Install CMake via APT
Open your terminal (press Ctrl+Alt+T or search for “Terminal” in the app menu) and run the following command:
sudo apt install cmake
Verify Installation
After installation completes, confirm that CMake is ready by checking its version:
cmake --version
This method works reliably for most development tasks and installs the version available in Ubuntu’s repository.
Method 2: Install CMake by Compiling Source
Source compilation requires manual rebuilding whenever security patches or new releases appear. Ubuntu’s APT repository and Kitware’s official APT repository both handle updates automatically through your regular system update workflow, eliminating manual maintenance overhead.
For advanced users or those requiring the latest features, compiling from source delivers cutting-edge functionality and build customization options. This method involves downloading, building, and installing the source code manually.
Required Build Tools and Libraries
Before starting, install the necessary tools and libraries for the build process. The build-essential package includes GCC compiler and other essential build tools. Run the following command:
sudo apt install build-essential zlib1g-dev libssl-dev -y
Download Latest Source Archive
Next, visit the CMake GitHub Releases page and locate the latest .tar.gz source archive. Use wget to download it, replacing X.X.X with the desired version number:
wget https://github.com/Kitware/CMake/releases/download/vX.X.X/cmake-X.X.X.tar.gz
Extract Source Archive
Once downloaded, extract the archive using the tar command:
tar -zxvf cmake-X.X.X.tar.gz
After extraction completes, navigate to the extracted directory:
cd cmake-X.X.X
Build and Install
First, run the bootstrap script to configure the environment and check dependencies:
./bootstrap

Once complete, compile the source code using:
make

Finally, install the compiled CMake package:
sudo make install
This final step might take a few minutes to complete.

Verify Installation
After installation finishes, confirm the installation by checking the CMake version:
cmake --version
Method 3: Install CMake via Kitware APT Repository
Kitware maintains an official APT repository that provides newer CMake releases than Ubuntu’s default repositories without requiring source compilation. This method combines automatic updates with access to recent stable versions, making it ideal when you need newer features but want to avoid manual maintenance.
Remove Existing CMake Installation
First, if you previously installed CMake via Ubuntu’s default repository, remove it to avoid version conflicts:
sudo apt remove --purge cmake
Install Required Dependencies
Next, install the necessary tools to add the Kitware repository:
sudo apt update
sudo apt install ca-certificates gpg wget
Add Kitware GPG Key
Then, download and install Kitware’s signing key to verify package authenticity:
wget -qO- https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
Add Kitware Repository
Add the Kitware repository for your Ubuntu version. Replace $(lsb_release -cs) with your Ubuntu codename (such as jammy or noble) if detection fails, and keep the architecture filter so APT ignores unsupported i386 packages. This command uses the legacy repository format, which remains fully functional on all Ubuntu releases:
Kitware limits this repository to Ubuntu 24.04 LTS (noble), Ubuntu 22.04 LTS (jammy), and Ubuntu 20.04 LTS (focal) on x86_64 or ARM hardware. Future non-LTS releases and legacy versions fall outside official support, so stick with Ubuntu’s default packages or compile CMake from source if you run anything else.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/kitware.list
Update Package Lists and Install CMake
Finally, refresh the package cache and install CMake from Kitware’s repository:
sudo apt update
sudo apt install cmake
Verify Installation
Confirm the installation by checking the CMake version:
cmake --version
The output should display a version number from Kitware’s repository, typically newer than Ubuntu’s default package. Future updates will automatically install through your regular system update workflow.
Method 4: Install CMake via Snap
Snap packages provide containerized installations that run independently of system libraries, making them useful for isolated development environments or systems where you cannot modify global packages. Additionally, the CMake snap automatically updates to the latest stable release through Snap’s background refresh mechanism.
Install Snapd (if needed)
Most Ubuntu installations include snapd by default. Verify installation status with:
snap version
If the command fails, install snapd with the following commands:
sudo apt update
sudo apt install snapd
Install CMake Snap Package
Classic confinement grants the CMake snap full system access similar to traditionally installed packages. This differs from strict confinement that sandboxes applications. Classic mode is necessary for CMake to access project files and build directories across your filesystem without permission restrictions.
Install CMake using the classic confinement mode, which grants access to system files and directories necessary for build operations:
sudo snap install cmake --classic
The --classic flag allows CMake to interact with your development environment without sandbox restrictions that would prevent accessing project files outside your home directory.
Verify Installation
Confirm the snap installation by checking the version:
cmake --version
Snap automatically manages updates, typically refreshing to new stable releases within days of upstream publication. Use the following commands whenever you need to trigger manual updates or inspect the available channels:
sudo snap refresh cmake
snap info cmake
Testing Your CMake Installation
After installation completes, verify CMake works correctly by creating and building a simple “Hello, World!” program. This confirms the installation is functional and ready for development work.
Create Test Directory
Create a dedicated directory for the test project to keep files organized:
mkdir test-hello && cd test-hello
Set Up CMakeLists.txt
The CMakeLists.txt file is the heart of a CMake project, specifying the build configuration. First, use the nano editor to create this file in the test directory:
nano CMakeLists.txt
Next, add the following configuration to define the project and its executable:
cmake_minimum_required(VERSION 3.16)
project(HelloWorld)
add_executable(hello main.cpp)
cmake_minimum_required: Ensures the CMake version meets the minimum required for the project.project: Names the project, in this case,HelloWorld.add_executable: Specifies the executable target and its source file.
Save and exit the editor by pressing CTRL+X, then Y, and finally Enter.
Create C++ Source File
Next, write a basic C++ program to print “Hello, World!” to the terminal. Create main.cpp in the same directory:
nano main.cpp
Then, enter the following code into the file:
#include <iostream>
int main()
{
std::cout << "Hello, World!" << std::endl;
return 0;
}
This code uses the C++ standard library to output “Hello, World!” to the terminal. Save and close the file using the same process as before (CTRL+X, Y, Enter).
Generate Build System
Now, generate the build system using CMake:
cmake .
CMake processes CMakeLists.txt and generates a Makefile in the current directory.
Build the Program
Next, compile the program using make, which reads the generated Makefile and builds the hello executable:
make
The terminal output will display the compilation process, confirming the creation of the hello executable.
Run the Program
Finally, run the compiled program to verify everything works correctly:
./hello
You should see the following output in the terminal:

This confirms that CMake is installed and functioning as expected on your system.
Common Issues and Solutions
While CMake installation typically proceeds smoothly, certain scenarios can cause errors. The solutions below address the most common issues encountered on Ubuntu systems.
Missing Build Dependencies During Source Compilation
If the bootstrap script fails with “Could not find OpenSSL” or similar library errors, you’ll need to install the missing development packages. The build-essential package group covers most requirements, but additional libraries may be needed.
First, check for the specific error message:
./bootstrap
You may see output similar to:
CMake Error: Could not find OpenSSL CMake Error: CMAKE_USE_OPENSSL is ON but a SSL library is not found!
Install the missing development libraries:
sudo apt install libssl-dev libcurl4-openssl-dev
After installing dependencies, run bootstrap again to verify the issue is resolved.
Version Conflicts with Existing Installations
When multiple CMake versions exist (APT package plus manual source build), check which binary your shell finds:
which cmake
The output shows the active path:
/usr/bin/cmake
Check all installed versions:
/usr/bin/cmake --version
/usr/local/bin/cmake --version
If both versions exist, you have two options. First, remove the APT package to avoid conflicts:
sudo apt remove cmake
Alternatively, ensure /usr/local/bin precedes /usr/bin in your PATH environment variable to prioritize the source-compiled version. Check your current PATH:
echo $PATH
Verify the source-compiled version is now active:
cmake --version
Slow Source Compilation on Limited Hardware
Compiling CMake on systems with fewer than 2 CPU cores or limited RAM can take 30-60 minutes. To accelerate the build, limit parallel jobs to match available cores.
Check your CPU core count:
nproc
Example output showing 2 cores:
2
Replace the standard make command with a parallelized version matching your core count:
make -j2
For systems with 4 cores, use the following command to maintain reasonable build speed without exhausting memory:
make -j4
The compilation will show multiple files building simultaneously:
[ 10%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmakefile.cxx.o [ 11%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmSourceFile.cxx.o [ 12%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmTarget.cxx.o ...
Permission Denied During make install
The installation step writes to system directories requiring root access. If make install fails with permission errors, you’ll see output similar to:
CMake Error at cmake_install.cmake:41 (file): file INSTALL cannot copy file "/home/user/cmake-3.30.0/bin/cmake" to "/usr/local/bin/cmake". Call Stack (most recent call first): cmake_install.cmake:99 (include)
The simplest solution is to prefix the command with sudo:
sudo make install
Alternatively, configure a user-writable installation prefix during bootstrap to avoid needing elevated privileges. This installs CMake to your home directory:
./bootstrap --prefix=$HOME/.local
Then complete the build and install without sudo:
make
make install
Verify CMake is accessible from your PATH:
~/.local/bin/cmake --version
Add $HOME/.local/bin to your PATH if needed by adding this line to ~/.bashrc:
export PATH="$HOME/.local/bin:$PATH"
Conclusion
CMake delivers efficient cross-platform build automation for C and C++ projects through its declarative configuration system. Ubuntu offers multiple installation paths to match different workflow requirements: the default APT repository balances stability and maintenance simplicity, Kitware’s official repository provides newer releases with automatic updates, Snap packages offer containerized isolation, and source compilation grants access to cutting-edge features with full customization. Your Ubuntu system now runs a working CMake installation verified through a functional Hello World example, ready for production builds or development environments.
Useful CMake Links
Here are some helpful resources to further enhance your understanding and usage of CMake. These links are directly related to the content covered in this guide and provide additional support for both beginners and advanced users:
- CMake Getting Started Guide
Explore the official CMake getting started guide to familiarize yourself with the basics of using CMake for your projects. - CMake Documentation
Access the comprehensive documentation for CMake, covering everything from basic commands to advanced usage and customization. - CMake Support Page
If you need help or have questions about CMake, visit the official support page for FAQs, forums, and additional resources. - CMake GitHub Repository
Stay updated with the latest CMake releases, source code, and contributions by exploring its GitHub repository.
Thank you for taking the time to reply to my previous comment. I just wanted to clarify that the files in this link: https://github.com/Kitware/CMake/releases, do not include the boostrap script and other files you mentioned. The instructions do work but I had to download the file from this link: https://cmake.org/download.
I just thought that might be useful for others.
Hi again Roberto,
I am still at a loss how the GitHub download link did not show bootstrap and the other additional files, I downloaded Source code (tar.gz) yesterday and today and https://github.com/Kitware/CMake/archive/refs/tags/v3.28.2.tar.gz and it was in it and its exactly the same as the link on https://cmake.org/download.
Regardless, if it works now that’s great and the main thing, I should put this down as the main download location as its more simple for just grabbing the source to compile, the GitHub page is good if you need a pacific source as it contains much more than the source if you want CMake via another option, but it can be confusing.
Thanks for the feedback anyway.