How to install cmake 3.2 on Ubuntu

Either use a PPA or compile it yourself:

  1. Installation by a PPA (Upgrade to 3.2)

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:george-edison55/cmake-3.x
    sudo apt-get update
    
    • When cmake is not yet installed:

      sudo apt-get install cmake
      
    • When cmake is already installed:

      sudo apt-get upgrade
      
  2. Compile it yourself

    Currently, the latest version is 3.2.2, the following instructions based on this version. You should therefore check this URL and adjust the file name accordingly.

    sudo apt-get install build-essential
    wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz
    tar xf cmake-3.2.2.tar.gz
    cd cmake-3.2.2
    ./configure
    make
    

    Now you can have to choose an installation type to decide, I recommend installing with checkinstall, as this creates a DEB package.

    • With checkinstall

      sudo apt-get install checkinstall
      sudo checkinstall
      
    • With make install

      sudo make install
      

There are three options:

  • install from a PPA
  • install the pre-built binary distribution from cmake.org
  • compile it yourself

Installation from PPA

sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update

When cmake is not already installed:

sudo apt-get install cmake

When cmake is already installed:

sudo apt-get upgrade

Installation from cmake.org binary distrubtion

curl -sSL https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz | sudo tar -xzC /opt

CMake executables will be in /opt/cmake-3.5.2-Linux-x86_64/bin/.

Compile it yourself

Currently, the latest version is 3.5.2, the following instructions based on this version. You should therefore check the download page and adjust the file name accordingly.

sudo apt-get install build-essential
wget http://www.cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar xf cmake-3.5.2.tar.gz
cd cmake-3.5.2
./configure
make

Now you can have to choose an installation type to decide, I recommend installing with checkinstall, as this creates a DEB package.

  • with checkinstall

    sudo apt-get install checkinstall
    sudo checkinstall
    
  • with make install

    sudo make install
    

I am not sure if I am late to the party, but recently on Ubuntu 14.04 I faced same issues and this is how I got it solved. First, you need to remove the existing cmake by executing the command:

sudo apt-get remove cmake

Hit return or enter. Next, you need to install cmake3 by using the following commands:

sudo apt-get update 

sudo apt-get upgrade 

sudo apt-get install cmake3

Assuming, my answer will get old in few years, consider searching for a cmake package that has a number associated with it. For example, at this time, cmake3 works for me.

To do so, all you have to execute is

apt-cache search cmake

Once you find the package, just install as suggested.

Thank you
Happy Coding!