| by Arround The Web | No comments

3 Ways to Install CMake on Raspberry Pi

CMake is an open-source tool that uses the configuration file named “CMakeLists” to generate and build files on your system. You can use this tool to easily build those packages or software that require a compiler, as it uses the compiler-independent method to install the application on your system quickly.

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.

$ sudo apt update && sudo apt upgrade

Step 2: Install CMake

You can now install CMake from the Raspberry Pi repository using the following command:

$ sudo apt install cmake -y

Step 3: Confirm the CMake Installation

To confirm whether CMake is installed properly, you can use the following command:

$ cmake --version

Remove CMake from Raspberry Pi

You can remove CMake from Raspberry Pi via the following command:

$ sudo apt --purge remove cmake -y

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:

$ sudo apt install libssl-dev -y

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:

$ wget https://github.com/Kitware/CMake/releases/download/v3.25.0-rc4/cmake-3.25.0-rc4.tar.gz

Step 3: Extract CMake Content

To extract the CMake file content from the tar.gz file, use the following command:

$ tar -xf cmake-3.25-0.rc4.tar.gz

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:

$ cd cmake-3.25.0-rc4

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:

$ ./bootstrap

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.

$ gmake

Alternatively, you can run the following command to ensure the successful installation of CMake on your Raspberry Pi system.

$ sudo make install

To confirm the latest version of CMake installed on your system, apply the following command:

$ cmake --version

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:

$ sudo apt install snapd -y

Step 2: Install core package from the snap store using the following command to install an updated version of the software.

$ sudo snap install core

Step 3: Now, you can install CMake from the snap store through the following command:

$ sudo snap install cmake --classic

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.

$ sudo snap remove cmake

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.

Share Button

Source: linuxhint.com

Leave a Reply