In this article, I will take you through the steps to install cmake on Ubuntu 20.04 LTS (Focal Fossa). CMake is cross-platform free and open-source software for build automation, testing, packaging and installation of software by using a compiler-independent configuration files. It generate native makefiles and workspaces that can be used in the compiler environment of your choice. It was designed as in response to the need for a powerful, cross-platform build environment for open-source projects such as ITK and VTK. More on official website. cmake can be easily installed in any Linux based systems. Here we will see the steps to install on Ubuntu 20.04 LTS Server.
How to Install cmake on Ubuntu 20.04 LTS (Focal Fossa)
Step 1: Prerequisites
a) You should have a running
Ubuntu 20.04 LTS Server.
b) You should have
root access to run privileged commands.
c) You should have
apt-get utility available in your System.
Step 2: Update Your Server
First you need to update the system cache with all the latest available updates from Ubuntu repo by using
sudo apt update command as shown below.
cyberithub@ubuntu:~$ sudo apt update Hit:1 https://download.docker.com/linux/ubuntu focal InRelease Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease Hit:3 http://in.archive.ubuntu.com/ubuntu focal InRelease Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Get:5 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Get:6 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB] Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [712 kB] Get:8 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,072 kB] Fetched 3,120 kB in 3s (953 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done
Step 3: Install cmake
Next step is to install cmake by using
sudo apt install cmake command as shown below. This will download and install the package from default Ubuntu repo along with all its dependencies.
cyberithub@ubuntu:~$ sudo apt install cmake [sudo] password for cyberithub: Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: cmake-data libjsoncpp1 librhash0 Suggested packages: cmake-doc ninja-build The following NEW packages will be installed: cmake cmake-data libjsoncpp1 librhash0 0 upgraded, 4 newly installed, 0 to remove and 46 not upgraded. Need to get 5,470 kB of archives. After this operation, 28.3 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 cmake-data all 3.16.3-1ubuntu1 [1,612 kB] Get:2 http://in.archive.ubuntu.com/ubuntu focal/main amd64 libjsoncpp1 amd64 1.7.4-3.1ubuntu2 [75.6 kB] Get:3 http://in.archive.ubuntu.com/ubuntu focal/main amd64 librhash0 amd64 1.3.9-1 [113 kB] Get:4 http://in.archive.ubuntu.com/ubuntu focal/main amd64 cmake amd64 3.16.3-1ubuntu1 [3,669 kB] Fetched 5,470 kB in 2s (2,541 kB/s) Selecting previously unselected package cmake-data. (Reading database ... 217801 files and directories currently installed.) ........................................
Step 4: Verify the Package
Once the package installed successfully, you can verify the installed files location by using
dpkg -L cmake command as shown below.
cyberithub@ubuntu:~$ dpkg -L cmake /. /usr /usr/bin /usr/bin/cmake /usr/bin/cpack /usr/bin/ctest /usr/share /usr/share/bash-completion /usr/share/bash-completion/completions /usr/share/bash-completion/completions/cmake /usr/share/bash-completion/completions/cpack /usr/share/bash-completion/completions/ctest /usr/share/cmake /usr/share/cmake/debtoolchainfilegen /usr/share/doc /usr/share/doc/cmake /usr/share/doc/cmake/NEWS.Debian.gz /usr/share/doc/cmake/changelog.Debian.gz /usr/share/doc/cmake/copyright /usr/share/man /usr/share/man/man1 /usr/share/man/man1/cmake.1.gz /usr/share/man/man1/cpack.1.gz /usr/share/man/man1/ctest.1.gz
Step 5: Check cmake version
You can also verify the current installed version by running
cmake --version command as shown below.
cyberithub@ubuntu:~$ cmake --version cmake version 3.16.3 CMake suite maintained and supported by Kitware (kitware.com/cmake).