In this tutorial, you will see the procedure to install CMake on your Raspberry Pi system with a simple example to test it on the system.
3 Ways to Install CMake on Raspberry Pi
By default, the Raspberry Pi system does not include CMake installation; however, you can install this tool from three methods:
Method 1: Install CMake Through Raspberry Pi Repository
You can install CMake through Raspberry Pi repository from following steps:
Step 1: Update Packages
Make sure to run the following command before installing any package from the Raspberry Pi repository as this will help you install an updated version of a package.
Step 2: Install CMake
You can now install CMake from the Raspberry Pi repository using the following command:
Step 3: Confirm the CMake Installation
To confirm whether CMake is installed properly, you can use the following command:
Remove CMake from Raspberry Pi
You can remove CMake from Raspberry Pi via the following command:
Method 2: Install CMake From Source
To install the latest version of CMake, follow the below-mentioned steps:
Step 1: Install Prerequisite on Raspberry Pi
First you must install OpenSSL library on your Raspberry Pi system from the following command as this is required during the installation process:
Step 2: Download CMake Source File
Now, download the latest version of CMake source file from the website. Since the latest version at the time of writing this article is “3.25.0”, so I have to choose the below-mentioned command:
Step 3: Extract CMake Content
To extract the CMake file content from the tar.gz file, use the following command:
Make sure to replace the version in the above command if you are installing a different version.
Step 4: Navigate to CMake Folder
The above command extracts the CMake contents in a folder “cmake-3.25.0-rc4” and to navigate to this folder, you can use the following command:
Step 5: Execute the CMake Installation File
Within the CMake directory, you must execute the “bootstrap” file through the following command to prepare the CMake installation file:
The process will take time since it prepares and builds many files required to install CMake on your Raspberry Pi system.
Step 5: Install CMake
After successfully building the installation files, you can use the following command to install CMake on your Raspberry Pi system.
Alternatively, you can run the following command to ensure the successful installation of CMake on your Raspberry Pi system.
To confirm the latest version of CMake installed on your system, apply the following command:
Method 3: Install CMake from Snap Store
You can also install CMake on Raspberry Pi from the snap store through the following steps:
Step 1: First install snap demon using the following command on Raspberry Pi system’s terminal:
Step 2: Install core package from the snap store using the following command to install an updated version of the software.
Step 3: Now, you can install CMake from the snap store through the following command:
Remove CMake from Snap Store
You can use the following command to successfully remove CMake from the snap store in case you don’t need it anymore.
Conclusion
CMake is a tool for building compiler-based packages, as it helps you install these packages from a source without using any compiler. You can install this tool from the Raspberry Pi repository, source file, or snap store. The installation from the repository is easy, but it won’t install the updated version of CMake on Raspberry Pi. However, you can follow the source file method to install the latest version of CMake, which can take time, but it will successfully install the tool on your Raspberry Pi system. You can also install CMake from the snap store but in this case, you may not get the latest version.