Installing CMake

There are several ways to install CMake, depending on your platform.

Windows

There are pre-compiled binaries available on the Download page for Windows as MSI packages and ZIP files. One may alternatively download and build CMake from source. The Download page also provides source releases. In order to build CMake from a source tree on Windows, you must first install the latest binary version of CMake because it is used for building the source tree. Once the binary is installed, run it on CMake as you would any other project. Typically this means selecting CMake as the Source directory and then selecting a binary directory for the resulting executables.

Linux, macOS, UNIX

There are pre-compiled binaries available on the Download page for some UNIX platforms. One may alternatively download and build CMake from source. The Download page provides source releases.  There are two possible approaches for building CMake from a source tree.  If there is no existing CMake installation, a bootstrap script is provided:

  ./bootstrap
  make
  make install

(Note: the make install step is optional, cmake will run from the build directory.)

By default bootstrap will build CMake without any debug or optimization flags. To enable optimizations you will need to specify the CMAKE_BUILD_TYPE option to bootstrap like this: ./bootstrap -- -DCMAKE_BUILD_TYPE:STRING=Release

For more options with bootstrap, run ./bootstrap --help  .

Or, an existing CMake installation can be used to build a new version:

  cmake .
  make      
  make install

(Note: the make install step is optional, cmake will run from the build directory.) If you are not using the GNU C++ compiler, you need to tell the bootstrap script (or cmake) which compiler you want to use. This is done by setting the environment variables CC and CXX before running it. For example:

  env CC=cc CXX=CC ./bootstrap
  make
  make install

Download Verification

Each release on the Download page comes with a file named cmake-$version-SHA-256.txt, where $version is the release version number.
One may use this file to verify other downloads, such as the source tarball. For example:

  $ curl -OL https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1-SHA-256.txt
  $ curl -OL https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1.tar.gz
  $ sha256sum -c --ignore-missing cmake-3.20.1-SHA-256.txt
  cmake-3.20.1.tar.gz: OK

The SHA-256 file itself can be verified by GPG signature:

  $ curl -OL https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1-SHA-256.txt.asc
  $ gpg --keyserver pool.sks-keyservers.net --recv-keys C6C265324BBEBDC350B513D02D2CEF1034921684
  $ gpg --verify cmake-3.20.1-SHA-256.txt.asc cmake-3.20.1-SHA-256.txt

The GPG key C6C265324BBEBDC350B513D02D2CEF1034921684 is a signing subkey whose expiry is updated yearly.