CMake is the software used for building, automation, testing, and installing different applications by using their source code. CMake can be installed on different distributions of Linux using the command line interface and the graphical user interface.
This blog demonstrates different methods of installing CMake on Ubuntu 22.04. The outlines of this guide are as follows:
- Using Snap Store to Install CMake on Ubuntu 22.04
- Using Ubuntu Software to Install CMake on Ubuntu 22.04
- Using GitHub to Install CMake on Ubuntu 22.04
Let’s start with the first one:
Method 1: Using Snap Store to Install CMake on Ubuntu 22.04
CMake is obtained on various Linux distributions through the snap store. The snapcraft tool is used to manage these snaps. The snap support is available on Ubuntu 22.04 by default. Just use the below-mentioned command to install CMake:
$ sudo snap install cmake --classic
To confirm the installation of the CMake package, display its version using the command:
$ cmake --version
It can be seen that the “3.24.1” version of the CMake is successfully installed.
Remove CMake Using CLI
If the package is installed through the snap store, it can easily be removed from the system as follows:
$ sudo snap remove cmake
The package has been removed as displayed on the screen.
Method 2: Using Ubuntu Software to Install CMake on Ubuntu 22.04
This method uses the Ubuntu software application to install CMake on Ubuntu 22.04. Let’s see how it can be installed:
Go to the search bar of “Applications”, type “ubuntu software” and click on its icon to open the Ubuntu application store:
When the Ubuntu software application is launched, search for CMake package by typing the “cmake”:
Click on the CMake package and then navigate to the “Install” button:
It will ask the password for the authentication purpose, provide the password to proceed to next step:
When the installation is complete, go to the search bar of applications, and find “cmake”:
Click on the icon, and the CMake application will be launched:
Remove CMake Using GUI
To remove it, open the “Ubuntu Software Center”:
Search for “cmake” and click on the “Installed” version:
Following this, the “Trash” icon can be seen, click on it to remove the “CMake”:
A new pop-up will appear to confirm the uninstallation; click on “Uninstall”:
It will ask for the “sudo” password, type it and hit “Authenticate”:
After successful authentication, the “CMake” will be removed from the system.
Method 3: Using GitHub to Install CMake on Ubuntu 22.04
GitHub comprises a list of packages provided for users to install them. This method installs the CMake from GitHub using the steps provided below:
Step 1: Install the dependencies
First, install the required dependencies to manage the source files from GitHub:
$ sudo apt install build-essential libssl-dev
Step 2: Download the tar file of CMake
Then, download the CMake package from GitHub using the command:
$ wget -c https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1.tar.gz
Step 3: Extract the Downloaded tar file
When the package is downloaded, extract its files via the command:
$ tar -zxvf cmake-3.20.1.tar.gz
Navigate to the extracted folder by using the command:
$ cd cmake-3.20.1
Step 4: Run the Bootstrap Script
Now, run the command to compile the package with the execution of the command:
$ sudo ./bootstrap
Step 5: Build the Package
This will take some time, so when the command is executed completely, run the command:
$ sudo make
Step 6: Install CMake
When all the packages are built up, then run the installation command of CMake:
$ sudo make install
To confirm the installation, display the version with the command:
$ cmake --version
The Cmake’s version “3.22.1” has been installed using this method. That’s all from this detailed installation guide!
Conclusion
The package of CMake can be installed by three different methods, the most convenient method is by running the command “sudo snap install cmake –classic” on Ubuntu 22.04. In this blog, three different installation methods of CMake have been explored. The CMake is available on the snap store and the Ubuntu default repository; therefore, it can be installed using the CLI and GUI of Ubuntu 22.04. Moreover, one can also use the source packages of CMake from GitHub to install it on Ubuntu 22.04.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY