Install Cmake

In this article, we have explained how to build and install Cmake in any system with OS Linux, Ubuntu and Windows.

Table of contents:

  1. Introduction to Cmake
  2. Get Cmake binary
  3. Build and install Cmake
  4. Check Cmake installation

Introduction to Cmake

Cmake is an open-source system that is used to manage the build process of production systems. It is frequently used to build and install other critical softwares like Clang.

The configuration of the system is saved in CMakeLists.txt file of Cmake which is used to prepare the build files for make tool.

Get CMake binary

For Linux systems, you need to download the file cmake-3.22.3.tar.gz. The command to download it will be:

wget https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3.tar.gz

For Windows system, you need to download "cmake-3.22.3.zip" and for MacOS, you need to download "cmake-3.22.3-macos10.10-universal.tar.gz".

To download the latest source code, use the following command:

git clone https://github.com/Kitware/CMake.git

Go into the directory of Cmake source code:

cd CMake

Build and install Cmake

  • Use the following command after extracting the download file:
./bootstrap
make -j 16
sudo make install

If your system does not have "make", you can install it using the following command:

sudo apt-get install build-essential

OR

sudo apt-get -y install make

Alternatively, you can use the following commands to build and install Cmake:

mkdir cmake-build && cd cmake-build
../cmake-source/bootstrap && make

Check Cmake installation

To check Cmake installation, we can check the version:

cmake -v

If it returns the correct value, you have successfully install Cmake in your system. Enjoy.