How to install cmake 3.7 in Ubuntu 16.04 using its binary archive file? [duplicate]

I'm on Ubuntu 16.04. I installed cmake with the command

sudo apt install cmake

It installed cmake 3.5.1. Now I want to use cmake 3.7 - I downloaded an archive with binaries (i.e cmake-3.7.0-Linux-x86_64.tar.gz) and extracted it, but how do I run it using the cmake command? My current attempt to run

cmake --version

returns the "old" 3.5.1 version.


Solution 1:

Remove old version using:

apt-get purge cmake

You can use new version of cmake by adding its bin directory path to $PATH. An alternative solution is to extract tar.gz package and go to the directory made after extracting and run following commands:

cp -r bin /usr/
cp -r doc /usr/share/
cp -r man /usr/share/
cp -r share /usr/

The second method is the same as installation process which .deb package does!