Installing and use cmake 3.4.1 in Ubuntu 14.04 using alternatives

Written by - 5 comments

Published on - Listed in Linux


Due to a developer request I needed to install the latest cmake 3.4.1 on an Ubuntu 14.04 LTS, however in trusty the cmake version is somewhat outdated (2.8.12) and there are no newer version in trusty-backports either.

On Ubuntu PPA I found a personal repository from Nathan Osman for cmake 3.x packages which sounds about the right source. Unfortunately this PPA does not contain the 3.4.1 version yet, so I had to go and compile cmake myself.

Compiling of cmake is pretty straight forward:

wget http://www.cmake.org/files/v3.4/cmake-3.4.1.tar.gz
tar -xvzf cmake-3.4.1.tar.gz
cd cmake-3.4.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.4.

sudo make install

Now I wanted to tell Ubuntu that the cmake command is now being replaced by an alternative installation. This can be done using update-alternatives:

update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force

This tells Ubuntu to create a new alternative for /usr/bin/cmake by using /usr/local/bin/cmake. The name of this replacement/alternative is "cmake". In my case I needed to add --force because cmake was already installed and the /usr/bin/cmake binary wasn't replaced with the symlink otherwise.

Now cmake is available system wide and can be launched with the new 3.4.1 version:

cmake --version
cmake version 3.4.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).


Add a comment

Show form to leave a comment

Comments (newest first)

alxcancado from Brazil wrote on Feb 3rd, 2018:

Thank you! I just installed in ethOS (ubuntu based)


Craig from USA wrote on Apr 4th, 2017:

Terrific write-up! Worked well for me, except the "update-alternatives" command gave me this error:

update-alternatives: using /usr/local/bin/cmake to provide /usr/bin/cmake (cmake) in auto mode
update-alternatives: error: error creating symbolic link `/etc/alternatives/cmake.dpkg-tmp': Permission denied

I just had to precede the command with "sudo" and the rest was fine. Not sure if everyone needs to, but thought I'd mention it. In my case, I was installing cmake 3.7.2 onto Ubuntu 14.04.


suek0 from Spain wrote on Feb 23rd, 2017:

Very useful!
Thanks a lot.


suek0 from Spain wrote on Feb 23rd, 2017:

Very useful!
Thanks a lot.


guar from wrote on May 10th, 2016:

It was very useful, since I am total newbie with Ubuntu. It saved me a lot of time. Thank you!


RSS feed

Blog Tags:

  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