Note: This article applies not only to Ubuntu 14.04 but also later Ubuntu versions. Today (June 6th 2019) I successfully applied the same steps on Ubuntu 18.04 Bionic.
In a previous article, I described how it's possible to Install/Upgrade cmake 3.10.1 in Ubuntu 14.04 using alternatives.
Since then a couple of new versions were released and the same procedure can still be used to install cmake 3.12.1.
Download and compile:
$ wget http://www.cmake.org/files/v3.12/cmake-3.12.1.tar.gz
$ tar -xvzf cmake-3.12.1.tar.gz
$ cd cmake-3.12.1/
$ ./configure
$ make
Make's install command installs cmake by default in /usr/local/bin/cmake, shared files are installed into /usr/local/share/cmake-3.10.
Now it's time to create a backup, in case you need to roll back to the old version:
$ /usr/local/bin/cmake --version
cmake version 3.10.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ sudo cp -p /usr/local/bin/cmake{,.3.10.1}
$ ll /usr/local/bin/cmake*
-rwxr-xr-x 1 root root 16509675 Dez 22 2017 /usr/local/bin/cmake
-rwxr-xr-x 1 root root 16509675 Dez 22 2017 /usr/local/bin/cmake.3.10.1
To install (copy) the binary and libraries to the new destination, run:
$ sudo make install
If you haven't already installed a newer cmake installation, run the following command to tell Ubuntu that the cmake command is now being replaced by an alternative installation:
$ sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force
If you already have a custom cmake version installed (in my case I still had the 3.10.1 version active), the update-alternatives command is not necessary.
The make install command will replace the existing binary in /usr/local/bin/cmake. This can be verified using:
$ cmake --version
cmake version 3.12.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Alain from wrote on Oct 31st, 2019:
Good tutorial, thanks. Would be worthwhile to make two tweaks:
1) Suggests users download and build in a temporary folder (eg. $HOME/tmp)
2) After installation is complete, the temporary folder can be deleted
tayyab from Pakistan wrote on Oct 25th, 2019:
Thanks for your helpful insights on installing cmake.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office OpenSearch PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder