How to install the latest cmake version on Ubuntu ?

If you are trying to compile some opensource software which using cmake for the compilation, some of the .cmake file used by that opensource code might contains the requirement check for version as,

cmake_minimum_required(VERSION 3.11)

Due to this version check, if your default Ubuntu installed cmake version is less than 3.11, [ As in our case, on Ubuntu 18.04, default cmake version is 3.10.2 ], you will see an error like as below,

CMake Error at CMakeLists.txt:25 (cmake_minimum_required):
  CMake 3.11 or higher is required.  You are running version 3.10.2

To solve this dependency check, we will need to upgrade the cmake version to latest, which can be done on Ubuntu 18.04 as below,

Remove current cmake as,

$ sudo apt remove cmake 

Make sure you have “pip” installed, if not, install as mentioned in “How to Install Pip on Ubuntu”

Now, install cmake as,

 sudo pip install cmake --upgrade 

Check the version of pip as,

$ which cmake
$ cmake --version
cmake version 3.13.3
Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question