How to reinstall the latest cmake version?

Edit: As GNUton has pointed out, the following only works on Ubuntu 16.04 and 18.04(Checked on June 2019).

Now CMake developer team in Kitware Inc provides APT repositiory. It allows you to install latest CMake via apt-get.

  1. If you are using a minimal Ubuntu image or a Docker image, you may need to install the following packages:

    sudo apt-get update
    sudo apt-get install apt-transport-https ca-certificates gnupg \
                             software-properties-common wget
    
  2. Obtain a copy of our signing key:

    wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc |
        sudo apt-key add -
    
  3. Add the repository to your sources list and update.

    For Ubuntu Bionic Beaver (18.04):

    sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
    sudo apt-get update
    

    For Ubuntu Xenial Xerus (16.04):

    sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main'
    sudo apt-get update
    
  4. ... Optional steps. See details in reference.
  5. ... Optional steps. See details in reference.

    Now call

    sudo apt-get install cmake
    

Reference: Kitware APT Repository.


As far as I know the best way to get the latest CMake version installed on any Linux is not by apt but using pip.

Remove the apt cmake and install the latest version from pip which can easily keep up-to-date.

apt remove cmake
pip install cmake --upgrade