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.
Install on macOS
On macOS, the recommended method is using Homebrew:
brew install cmakeOr download the macOS .dmg installer directly from the CMake download page.
Install on Linux
If you’re on Debian or Ubuntu, you would normally run:
sudo apt-get install -y cmakeHowever, distros often ship older releases. Check your current version first:
cmake --versionIf 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.
Option A: Install via precompiled binaries (Fastest)
Remove any outdated package:
sudo apt-get -y purge --auto-remove cmakePick 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"Option B: Build from source
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 wgetDownload 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 installVerify the installation
cmake --versionYou 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.