How to use higher version of CMake?

Problem

$ cmake <blabla>
 
CMake Error at CMakeLists.txt:x (cmake_minimum_required):
  CMake 3.15 or higher is required.  You are running version 3.10.2


-- Configuring incomplete, errors occurred!

For some reason, you are stuck with an old version of CMake and could not upgrade (or don't want to upgrade).

Solution

Download the binaries and use them without installation

https://cmake.org/files/

https://github.com/Kitware/CMake/releases

  • Download the .tar.gz package. e.g. "cmake-3.15.6-Linux-x86_64.tar.gz".
  • Extract it.
  • Update PATH to use new binaries:

    export PATH=~/Downloads/cmake-3.21.3-linux-x86_64/bin:$PATH
  • Use cmake command with your source again. It should work now.