Post Date: May 22, 2019
Last Updated: October 23, 2026
Introduction
CMake is an open-source, cross-platform build system generator that helps developers manage the build process of software projects. It generates build files for tools such as GNU Make and Ninja, making it easier to configure, compile, and install applications from source code.
Although CMake is available through most Linux package managers, installing it from source is useful when you need a specific version, want greater control over the installation, or require a version that is not available in your distribution’s repositories.
In this guide, we will explain how to download the CMake source code, extract the archive, configure the build environment, compile the source, and install CMake on a Linux system.
If you prefer installing CMake through your package manager, refer to our guide: How to Install CMake on Linux.
Prerequisites
Before proceeding with the installation, ensure that the following requirements are met:
- Linux operating system: A supported Linux distribution such as Ubuntu or Debian.
- Root or sudo access: Required to install CMake into a system-wide directory.
- Build tools: A C/C++ compiler, GNU Make, and other required development utilities.
- Internet connection: Required to download the CMake source archive.
- Available disk space: Sufficient space to download, compile, and install the source files.
Check the official CMake download page for the latest stable release and select a version compatible with your system and project requirements.
Step-by-Step Guide to Install CMake from Source
Step 1: Install the Required Dependencies
On Ubuntu or Debian, update the package list and install the necessary build tools.
sudo apt update sudo apt install build-essential wget ca-certificates
Verify that the compiler and Make utility are available.
gcc --version make --version
Step 2: Download the CMake Source Code
Navigate to the /root directory or another suitable working directory.
cd /root
Download the CMake source archive. The following example uses CMake version 3.14.4 from the original guide. For a new installation, replace the version and download URL with your selected release from the official CMake website.
wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4.tar.gz
The archive will be downloaded to the current directory.
Step 3: Extract the Source Archive
Use the tar command to extract the downloaded archive.
tar -xzf cmake-3.14.4.tar.gz
Move into the extracted source directory.
cd cmake-3.14.4
You can list the directory contents to confirm that the source files have been extracted.
ls
Step 4: Configure the CMake Build
Run the bootstrap script from the extracted source directory.
./bootstrap
The bootstrap script checks the build environment and prepares the configuration required to compile CMake.
This process may take several minutes, depending on your system’s performance and installed dependencies.
Wait until the configuration completes successfully before proceeding to the next step.
Note: Use ./bootstrap for the standard CMake source-build procedure rather than assuming that a ./configure script is available.
Step 5: Compile CMake from Source
After the configuration completes, run the following command to compile the source code.
make -j"$(nproc)"
The -j"$(nproc)" option allows Make to use the number of available processing units to perform parallel compilation.
Compilation time depends on the CPU, available memory, and system resources. If your server has limited memory, use a smaller number of parallel jobs, such as make -j2.
Wait for the compilation to finish successfully before continuing.
Step 6: Install CMake
Once compilation is complete, install CMake using the following command.
sudo make install
By default, the installation generally places CMake under /usr/local, making it available system-wide when the relevant directories are included in the system’s PATH.
Step 7: Verify the Installation
After the installation finishes, verify the installed CMake version.
cmake --version
For the example installation, the output should identify CMake version 3.14.4.
If the command reports a different version, check whether another CMake installation appears earlier in your PATH.
Installation Flowchart
The following flowchart summarizes the complete installation process.

How to Uninstall CMake
The uninstall procedure depends on how CMake was installed.
If CMake was installed through APT:
Use the following command to remove the package and its automatically installed dependencies that are no longer required.
sudo apt-get remove --auto-remove cmake
If CMake was compiled and installed from source:
The APT removal command does not normally remove a source installation under /usr/local. Check the installation prefix and remove the installed files using a suitable removal procedure. If the source build supports an uninstall target, check it before use; otherwise, remove only the files belonging to that installation.
Avoid deleting shared directories or files that may belong to other software.
Conclusion
Installing CMake from source on Linux gives you control over the version and installation process. By installing the required dependencies, downloading and extracting the source archive, running the bootstrap script, compiling the code, and installing the resulting files, you can set up CMake on your Linux system.
Finally, run cmake --version to confirm that the installation is working correctly. For production systems, choose a supported release that meets your project’s requirements and keep the installation updated as needed.
Frequently Asked Questions (FAQs)
1. Why should I install CMake from source instead of using APT?
Installing from source lets you select a specific version and use a release that may not be available in your distribution’s package repository. However, package-manager installation is generally easier to maintain and update.
2. How can I check whether CMake is installed correctly?
Run the following command:
cmake --version
It displays the version of CMake found through your current PATH.
3. What should I do if the CMake compilation fails?
Check the error messages for missing dependencies, compiler problems, insufficient memory, or configuration issues. Install the required dependencies, rerun ./bootstrap if necessary, and retry the compilation. For systems with limited memory, reduce the number of parallel Make jobs.
Related Articles
- How the Linux Kernel Handles Network Connections Using DNS and Routing
- Modifying File Timestamps in Linux Using touch
Need Assistance?
If you encounter issues installing CMake or configuring your Linux build environment, please contact the Pheonix Solutions support team. Include your Linux distribution, version, and any error messages so our team can investigate and assist you.
For further assistance, please contact our support team.
