Contents

How to install cmake?

CMake is a cross-platform tool for building, testing and packaging software.

If you’ve been writing C or C++ (or Fortran) you probably had to, at some point, use cmake to package your software.

On macOS, the recommended method is using Homebrew:

brew install cmake

Or download the macOS .dmg installer directly from the CMake download page.

If you’re on Debian or Ubuntu, you would normally run:

sudo apt-get install -y cmake

However, distros often ship older releases. Check your current version first:

cmake --version

If you need a newer version, you can either install from the Kitware APT repository (recommended for Debian/Ubuntu) or download precompiled binaries / build from source.

Remove any outdated package:

sudo apt-get -y purge --auto-remove cmake

Pick the target release from the GitHub releases page (e.g. 3.30.5) and download the precompiled binary script:

CMAKE_VERSION="3.30.5"
ARCH="$(uname -m)" # x86_64 or aarch64
wget "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
sudo sh "cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" --prefix=/usr/local --skip-license
rm "cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"

If you need custom build flags or want to build manually from source:

Install build dependencies:

sudo apt-get update && sudo apt-get install -y build-essential libssl-dev wget

Download and extract the source archive:

CMAKE_VERSION="3.30.5"
wget "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz"
tar -xzvf "cmake-${CMAKE_VERSION}.tar.gz"
cd "cmake-${CMAKE_VERSION}"

Build and install:

./bootstrap
make -j$(nproc)
sudo make install
cmake --version

You should see output similar to:

cmake version 3.30.5
CMake suite maintained and supported by Kitware (kitware.com/cmake).

For other platforms, check the official install guide.