How to Install CMake on Debian 13, 12 and 11

Last updated Sunday, May 17, 2026 12:47 pm Joshua James 8 min read 1 comment

CMake version choice matters on Debian because each release carries a different repository package while upstream CMake moves faster for new generator, policy, and language features. To install CMake on Debian, use APT for the distro-tested package, Snap for the current stable Snapcraft build, or a user-local source build when a project requires the newest upstream release.

APT is the safest default for most systems. Debian 13 currently provides CMake 3.31.x, Debian 12 provides 3.25.x, and Debian 11 provides 3.18.x from the default repositories, while Snap and upstream source builds can provide CMake 4.x without changing Debian’s package sources.

Install CMake on Debian

Choose a CMake Installation Method

Choose one method first so update and removal commands stay predictable. Mixing APT, Snap, and source-built CMake can leave multiple cmake binaries on your PATH.

MethodSource or ChannelUpdate BehaviorBest ForTrade-offs
APTDebian packagesUpdates through normal APT upgradesMost users, servers, and stable build environmentsVersion follows the Debian release
SnapSnapcraft stable channelUpdates through snap refreshUsers who need a newer CMake without compilingRequires snapd and classic confinement
Source buildKitware GitHub releasesManual rebuild for each releaseCustom prefixes, testing new releases, or project-specific requirementsLongest install path and manual maintenance

For a normal Debian workstation or server, install the APT package first. Use Snap when project requirements need the current upstream stable release, and keep source builds for cases where you explicitly want a versioned user-local install.

Check the Debian Repository Version

If the exact Debian package revision matters, check the candidate before installing:

apt-cache policy cmake
cmake:
  Installed: (none)
  Candidate: 3.31.6-2

The Candidate line shows the version your configured Debian repositories will install. Debian 13 currently reports a 3.31.x candidate, while Debian 12 and Debian 11 report older 3.x branches because each release freezes packages at a different point.

Refresh the APT Package Index

Refresh APT metadata before installing packages:

sudo apt update

These commands use sudo because package installation changes system directories managed by Debian.

Install CMake with APT

The APT method installs Debian’s cmake package and keeps updates tied to your normal system upgrade flow:

sudo apt install cmake

Verify the installed binary:

cmake --version
cmake version 3.31.6

Debian 13 currently shows a 3.31.x version from the default repository. Debian 12 and Debian 11 show older 3.x branches, so expect the first line to use this format with your release’s exact version.

Install CMake with Snap

The Snap package currently tracks CMake 4.x on amd64 and arm64 and uses classic confinement, which gives build tools broader filesystem access than a strict snap. If snapd is not already configured, install it from Debian’s repository first.

command -v snap

If the command prints nothing, install snapd from Debian’s repository. Start by refreshing APT metadata:

sudo apt update

Install the snapd package:

sudo apt install snapd

Enable the snapd socket so snap commands can talk to the local snap service:

sudo systemctl enable --now snapd.socket

Wait for snapd’s first-run setup to finish before installing CMake. This command is quiet when seeding has already completed:

sudo snap wait system seed.loaded

For a fuller snapd setup, session, and cleanup walkthrough, use the install Snapd on Debian guide before returning to the CMake-specific command.

Install the CMake snap with classic confinement:

sudo snap install cmake --classic

Verify that Snapcraft installed the CMake snap:

snap list cmake
Name   Version  Rev   Tracking       Publisher  Notes
cmake  4.3.2    1531  latest/stable  crascit**  classic

The Notes column confirms classic confinement. Next, run CMake through snapd so PATH setup does not affect the verification:

snap run cmake --version
cmake version 4.3.2

After a new login session, /snap/bin is usually added to your PATH, so the plain cmake command may work too. Use snap run cmake when you need a reliable command immediately after installing snapd.

Build the Latest CMake from Source

A source build is the most manual path, but it gives you a versioned user-local install that does not overwrite Debian’s /usr/bin/cmake. The example uses CMake 4.3.2; check the releases page and update VERSION when a newer stable release is available.

Install the build dependencies first:

sudo apt install build-essential zlib1g-dev libssl-dev wget ca-certificates

Create a build workspace in your home directory. Keeping source files under your account avoids mixing temporary build files with system directories.

mkdir -p "$HOME/cmake-build"
cd "$HOME/cmake-build"

Set the CMake release you want to build. The current example uses 4.3.2:

VERSION=4.3.2

Download the source tarball from Kitware’s GitHub release assets. The wget command examples guide covers download flags if you need a refresher.

wget https://github.com/Kitware/CMake/releases/download/v${VERSION}/cmake-${VERSION}.tar.gz

Download the matching SHA-256 manifest from the same release:

wget https://github.com/Kitware/CMake/releases/download/v${VERSION}/cmake-${VERSION}-SHA-256.txt

wget prints progress, transfer speed, and a saved filename. Those progress lines vary by connection speed, so the important check comes from the checksum command.

ls cmake-${VERSION}.tar.gz cmake-${VERSION}-SHA-256.txt
cmake-4.3.2-SHA-256.txt
cmake-4.3.2.tar.gz

The filenames must use the same version number. If one download failed or the versions do not match, stop and correct that before extracting anything.

Verify the tarball before extracting it:

grep " cmake-${VERSION}.tar.gz$" "cmake-${VERSION}-SHA-256.txt" | sha256sum -c -
cmake-4.3.2.tar.gz: OK

Extract the source archive and enter the release directory. The tar command guide explains the extraction flags in more detail.

tar -xzf cmake-${VERSION}.tar.gz
cd cmake-${VERSION}

Configure the build for a versioned user-local prefix. This tells the installer to place files under $HOME/.local/cmake-4.3.2 instead of shared system paths:

./bootstrap --prefix="$HOME/.local/cmake-${VERSION}"

Bootstrap prints many compiler, library, and feature checks. A successful run returns you to the prompt without an error and leaves a Makefile in the source directory.

Compile CMake after bootstrap finishes:

make -j"$(nproc)"

This step can take several minutes. The output includes build percentages and target names, so it is normal to see many lines before the command finishes.

[ 98%] Building CXX object ...
[100%] Built target cmake

Install the compiled files into the user-local prefix:

make install

Create the directory that normally holds user-local command shortcuts:

mkdir -p "$HOME/.local/bin"

Create stable symlinks for the CMake tools. The symlinks let $HOME/.local/bin/cmake keep working after each versioned source build:

for tool in cmake ctest cpack; do
  ln -sfn "$HOME/.local/cmake-${VERSION}/bin/$tool" "$HOME/.local/bin/$tool"
done

Check whether your current shell already finds commands from $HOME/.local/bin:

printf '%s\n' "$PATH" | tr ':' '\n' | grep -Fx "$HOME/.local/bin"
/home/user/.local/bin

If the command prints nothing, add the path for future Bash sessions:

grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' "$HOME/.bashrc" || echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"

Update the current terminal too, so you do not need to close and reopen it before verifying CMake:

export PATH="$HOME/.local/bin:$PATH"

Verify the source-built CMake binary:

"$HOME/.local/bin/cmake" --version
cmake version 4.3.2

Optional: Create a Latest CMake Build Script

For manual maintenance, keep a Bash script that checks the latest CMake release, downloads the matching source tarball and checksum manifest, rebuilds CMake, and updates the user-local symlinks. Run it manually when you want to refresh a source-built install.

The script performs the same source-build workflow as the manual commands, but it automates the release lookup and symlink refresh:

  • It checks that required tools such as wget, make, g++, and sha256sum exist.
  • It reads the latest stable CMake release tag from GitHub and compares it with the active cmake --version output.
  • It downloads the source tarball and SHA-256 manifest, verifies the tarball, then builds and installs into a versioned directory under $HOME/.local.
  • It updates only the user-local cmake, ctest, and cpack symlinks. It does not delete older source-build directories.
cat <<'EOF' > "$HOME/cmake-build/update-cmake.sh"
#!/usr/bin/env bash
set -euo pipefail

# Confirm the commands needed for download, verification, and compilation exist.
for cmd in wget grep cut awk tar make gcc g++ sha256sum nproc; do
  if ! command -v "$cmd" >/dev/null 2>&1; then
    echo "Error: $cmd is required. Install the source-build dependencies first."
    exit 1
  fi
done

WORKDIR="$HOME/cmake-build"
PREFIX_ROOT="$HOME/.local"
BIN_DIR="$HOME/.local/bin"

# Keep downloads and extracted source trees in one reusable workspace.
mkdir -p "$WORKDIR" "$BIN_DIR"
cd "$WORKDIR"

# Read the latest release tag from GitHub, such as v4.3.2.
LATEST_TAG=$(wget -qO- https://api.github.com/repos/Kitware/CMake/releases/latest | grep -m1 -oE '"tag_name": "v[0-9][^"]*"' | cut -d '"' -f4)
if [ -z "$LATEST_TAG" ]; then
  echo "Error: Unable to determine the latest CMake version."
  exit 1
fi

LATEST_VERSION="${LATEST_TAG#v}"
ACTIVE_VERSION=""
if command -v cmake >/dev/null 2>&1; then
# Compare against whichever cmake command is active in the current PATH.
  ACTIVE_VERSION=$(cmake --version | awk 'NR == 1 {print $3}')
fi

if [ "$ACTIVE_VERSION" = "$LATEST_VERSION" ]; then
  echo "CMake is already up to date ($ACTIVE_VERSION)."
  exit 0
fi

# Remove only the workspace copy for the release being rebuilt.
rm -rf "cmake-${LATEST_VERSION}" "cmake-${LATEST_VERSION}.tar.gz" "cmake-${LATEST_VERSION}-SHA-256.txt"

wget "https://github.com/Kitware/CMake/releases/download/v${LATEST_VERSION}/cmake-${LATEST_VERSION}.tar.gz"
wget "https://github.com/Kitware/CMake/releases/download/v${LATEST_VERSION}/cmake-${LATEST_VERSION}-SHA-256.txt"

# Verify the tarball listed in Kitware's SHA-256 manifest before extraction.
grep " cmake-${LATEST_VERSION}.tar.gz$" "cmake-${LATEST_VERSION}-SHA-256.txt" | sha256sum -c -

tar -xzf "cmake-${LATEST_VERSION}.tar.gz"
cd "cmake-${LATEST_VERSION}"

# Build and install into a versioned user-local prefix.
./bootstrap --prefix="${PREFIX_ROOT}/cmake-${LATEST_VERSION}"
make -j"$(nproc)"
make install

# Refresh stable command names without touching Debian's /usr/bin/cmake.
for tool in cmake ctest cpack; do
  ln -sfn "${PREFIX_ROOT}/cmake-${LATEST_VERSION}/bin/$tool" "${BIN_DIR}/$tool"
done

echo "Installed CMake ${LATEST_VERSION} under ${PREFIX_ROOT}/cmake-${LATEST_VERSION}."
echo "Make sure ${BIN_DIR} appears before /usr/bin in your PATH."
EOF

Make the script executable once:

chmod +x "$HOME/cmake-build/update-cmake.sh"

Run it when you want to compile the latest stable CMake release:

"$HOME/cmake-build/update-cmake.sh"
cmake-4.3.2.tar.gz: OK
Installed CMake 4.3.2 under /home/user/.local/cmake-4.3.2.
Make sure /home/user/.local/bin appears before /usr/bin in your PATH.

Avoid running this script from cron. Source builds can fail because of dependency changes, network errors, or upstream build changes, so run it manually and review the output before removing any older versioned prefix.

Test CMake with a Sample Project

A small out-of-source build confirms that CMake can generate build files and that your compiler toolchain works.

If you installed CMake with APT or Snap, install the compiler toolchain before building the sample project:

sudo apt install build-essential

Create a project directory:

mkdir -p cmake-hello

Enter the new directory before writing the project files:

cd cmake-hello

Create a minimal CMakeLists.txt:

cat <<'EOF' > CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(HelloWorld)
add_executable(hello main.cpp)
EOF

Create the C++ source file:

cat <<'EOF' > main.cpp
#include <iostream>

int main()
{
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
EOF

Generate build files in a separate build directory. This keeps generated files away from your source files:

cmake -S . -B build

CMake should identify the compiler and finish by writing build files:

-- The CXX compiler identification is GNU
-- Build files have been written to: /home/user/cmake-hello/build

Compile the sample program from the generated build directory:

cmake --build build
[100%] Built target hello

Run the compiled binary:

./build/hello
Hello, World!

Update or Remove CMake on Debian

Update an APT CMake Install

APT updates CMake when Debian publishes package updates for your release. Refresh package metadata first:

sudo apt update

Then request an upgrade for only the CMake package:

sudo apt install --only-upgrade cmake

Update a Snap CMake Install

Snap refreshes installed snaps automatically, but you can request a CMake refresh manually:

sudo snap refresh cmake

Inspect available tracks and channels when you need to pin or switch CMake branches:

snap info cmake

Update a Source-Built CMake Install

For source builds, either rerun the source-build commands with a newer VERSION value or run the optional latest-release build script. Keep the old prefix until the new binary passes cmake --version and builds your project.

"$HOME/cmake-build/update-cmake.sh"

The script updates the cmake, ctest, and cpack symlinks in $HOME/.local/bin. It does not delete old versioned prefixes automatically.

After the new version is working, set the old version number you want to delete:

OLD_VERSION=4.3.2

Remove only that old versioned prefix:

rm -rf "$HOME/.local/cmake-${OLD_VERSION}"

Remove the APT Package

Remove the Debian package first:

sudo apt remove cmake

After removal, review and remove dependencies that APT no longer needs:

sudo apt autoremove

Remove the Snap Package

Remove the CMake snap and its snap-managed data snapshot:

sudo snap remove --purge cmake

This removes the CMake snap only. Remove snapd separately only when no other snaps on the system still need it.

Remove a Source-Built CMake Install

Set the source-build version you want to remove:

VERSION=4.3.2

Delete the matching versioned prefix:

rm -rf "$HOME/.local/cmake-${VERSION}"

Remove only symlinks that still point to the deleted prefix. This avoids removing a symlink that now points to a newer source-built version:

for tool in cmake ctest cpack; do
  target="$HOME/.local/cmake-${VERSION}/bin/$tool"
  if [ "$(readlink "$HOME/.local/bin/$tool" 2>/dev/null)" = "$target" ]; then
    rm -f "$HOME/.local/bin/$tool"
  fi
done

Confirm which CMake binary remains active:

command -v cmake

If a CMake binary is still present, check which version it reports:

cmake --version

Troubleshoot CMake on Debian

CMake Is Too Old for a Project

If a project rejects Debian’s packaged version with a cmake_minimum_required error, check the required version in the project’s CMakeLists.txt. Use Snap or the source-build method when the required CMake branch is newer than your Debian release provides.

grep -n 'cmake_minimum_required' CMakeLists.txt

The Snap CMake Command Is Not Found

If the snap installs successfully but the plain cmake command is not found, your current shell may not include /snap/bin yet. Run the snap directly or start a new login session:

snap run cmake --version

After logging out and back in, check the shortcut path:

command -v cmake
/snap/bin/cmake

Bootstrap Fails With OpenSSL Errors

If a source build reports missing OpenSSL libraries, the OpenSSL development headers are usually missing:

CMake Error: Could not find OpenSSL
CMake Error: CMAKE_USE_OPENSSL is ON but a SSL library is not found!
sudo apt install libssl-dev

Return to the CMake source directory and rerun bootstrap with the same prefix:

./bootstrap --prefix="$HOME/.local/cmake-${VERSION}"

The Source Build Is Not the Active CMake

If cmake --version still shows Debian’s repository package after a source install, check which binary your shell finds first:

command -v cmake
/usr/bin/cmake

Use the user-local binary directly to confirm the source-built copy works:

"$HOME/.local/bin/cmake" --version

If that command reports the expected version, put $HOME/.local/bin before system paths in the current terminal:

export PATH="$HOME/.local/bin:$PATH"

Learn More About CMake

Use these official resources when you need syntax details, generator behavior, policies, or upstream release information:

Conclusion

CMake is installed on Debian with a package source that matches your maintenance needs, and the sample project confirms the generator and compiler can build a working binary. Keep APT installs aligned with Debian updates, refresh Snap packages through snapd, or rebuild the user-local source prefix when upstream releases a version your projects require.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee

1 thought on “How to Install CMake on Debian 13, 12 and 11”

  1. All steps succeed without any problem. A very clear easy-to-understand tuto. Thanks a lot. Pierre
    HP Pavilion dv7-4302EZ (2011) ; Debian version 11.11 ; Xfce 4.16

    Reply
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: