CMake installation and upgrade: What worked & what didn’t?!

Dr. Muniba Faiza
4 Min Read

CMake is a widely used cross-platform build system that automates the process of compiling and linking software projects. In bioinformatics, CMake can be utilized to manage the build process of software tools and pipelines used for data analysis, algorithm implementation, and other computational tasks. However, managing the versions of CMake or upgrading it on Ubuntu (Linux) can be a trivial task for beginners. In this article, we provide methods for installing and upgrading CMake on Ubuntu.

What didn’t work!

I tried to install and upgrade my CMake from version 3.16 to 3.2x using different methods including: (If you prefer not to read this, you can jump to the next section for the installation instructions.)

  • pip3 (pip3 install cmake)
    It did install the latest CMake (version 3.29) but couldn’t find the location. I got errors while trying to install other software as follows:
    “Command ‘cmake’ not found,”, or
    “Requirement already up-to-date: cmake in /.local/lib/python3.8/site-packages (3.29.2)”
    bash: /usr/bin/cmake: No such file or directory
  • hash -r
    In one of my previous posts, I mentioned about this command. However, it works only when you have correctly installed the CMake version and want to upgrade. It can’t find the new path and you get errors like:
    “CMake Error: Could not find CMAKE_ROOT !!! CMake has most likely not been installed correctly. Modules directory not found in /home/user/.local/share/cmake-3.16 cmake version 3.16.3”
  • sudo apt install cmake
    You can install CMake from the repository but you will not be able to find its location.
  • sudo snap install cmake
    It also didn’t work for me. I got an error stating:
    Error: This revision of snap “cmake” was published using classic confinement
    and thus may perform arbitrary system changes outside of the security
    sandbox that snaps are usually confined to, which may put your system at
    risk.If you understand and want to proceed repeat the command including
    –classic.

None of the methods mentioned above worked for me. I had to uninstall CMake and reinstall it from scratch, as demonstrated in the following section.

What worked!

Preparing system

Update and upgrade your system first.

$ sudo apt-get update

$ sudo apt-get upgrade

Uninstall the previous version of CMake.

$ pip3 uninstall cmake

Downloading CMake

Clone the GitHub directory of CMake from here or use the following command. You can download it in any directory, I am downloading it in ‘Downloads‘.

$ git clone https://github.com/Kitware/CMake.git

Installing Prerequisites

Install the build dependency package necessary for CMake installation.

$ sudo apt install build-essential libssl-dev

Installing CMake

Let’s change to the CMake directory.

$ cd CMake/

Now run the bootstrap script present in the same directory.

$ ./bootstrap

It will take a few minutes to finish. After it finishes, run the make command:

$ make

After that, install CMake,

$ sudo make install

It will take a while to finish the installation.

After that, check your installation using the following command:

$ cmake --version

It should display the latest version.


 

Share This Article
Dr. Muniba is a Bioinformatician based in New Delhi, India. She has completed her PhD in Bioinformatics from South China University of Technology, Guangzhou, China. She has cutting edge knowledge of bioinformatics tools, algorithms, and drug designing. When she is not reading she is found enjoying with the family. Know more about Muniba
Leave a Comment

Leave a Reply