27

I am looking for a reliable PPA for cmake backports.

I need it for both Xenial and Trusty (travis-ci). Ideally I would like to have at least cmake 3.8.

muru
  • 207,970
Juan Leni
  • 2,218

3 Answers3

26

There is now an official CMake APT repository, hosted by Kitware (announcement), which has the latest CMake version. Currently, Ubuntu 16.04 (Xenial) and 18.04 (Bionic) are supported, but not Trusty. Instructions to set it up can be found at https://apt.kitware.com/ . I've reproduced key details here:

...

  1. If the kitware-archive-keyring package has not been installed previously, manually obtain a copy of our signing key:

    test -f /usr/share/doc/kitware-archive-keyring/copyright ||
    wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
    
  2. Add the repository to your sources list and update.

    For Ubuntu Noble Numbat (24.04):

    echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
    sudo apt-get update
    

    For Ubuntu Jammy Jellyfish (22.04):

    echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
    sudo apt-get update
    

    For Ubuntu Focal Fossa (20.04):

    echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
    sudo apt-get update
    
  3. If the kitware-archive-keyring package has not been installed previously, remove the manually obtained signed key to make room for the package:

    test -f /usr/share/doc/kitware-archive-keyring/copyright ||
    sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg
    

After this, sudo apt-get install cmake will install the latest CMake.

muru
  • 207,970
Justin
  • 361
  • Excellent - thank you for this info. As of July 2019, this repo supplied cmake 3.14.5 for Ubuntu 16.04. – davidA Jul 10 '19 at 01:51
  • 1
    This repository doesn't support the arm64 architecture. – Victor Lamoine Nov 12 '19 at 18:00
  • 1
    This also supports 20.04 LTS (focal) – Alex Reinking May 06 '20 at 20:10
  • To build and install arm64 / aarch64 .deb packages from Kitware git repository (tested on Jetson Nano with Ubuntu 18.04 and should work for later Ubuntu versions too): cd /tmp/ && git clone https://gitlab.kitware.com/debian/cmake.git && cd cmake && perl -pi -e 's|(verify-build-flags:)|$1\n\t\$(call \$(flag_action),BUILD_TESTING,OFF,"Skip tests")|' ./debian/rules && sudo mk-build-deps -irt 'apt -y' && dpkg-buildpackage -b -rfakeroot -us -uc && sudo apt -y install ../cmake*.deb (perl here is used to turn off tests because they take a long time and they add nothing to the binary package). – Lissanro Rayen Jan 21 '21 at 12:51
  • Where can we find the package index? I'd like to check which version of CMake is proposed for each OS. I went into bugs when using CMake 3.27 with pybind – Kiruahxh Oct 13 '23 at 08:11
  • You can now skip all of that, since kitware made a setup script (source); run this, then apt install cmake for latest. bash <(wget -qO- https://apt.kitware.com/kitware-archive.sh) – JWCS Jul 18 '24 at 19:52
18

I know I was asking for a PPA but in general terms any reliable deployment of cmake for 14.04/16.04 is good. Kitware's blog shows an answer:

https://blog.kitware.com/cmake-python-wheels/

They seem to officially support a pip wheels release. So you can get latest cmake just by doing:

pip install --upgrade cmake

In addition, if you are using virtualenv or conda, you can have different cmake versions at the same time.

Update: the pip package may show a low version number. At the moment, it is 0.8, however, it does install cmake 3.9

Juan Leni
  • 2,218
11

There seems to be no reliable PPA with the most modern version of cmake in place but if you are happy with using prebuilt binaries from the cmake download page the following should help (for 64bit Ubuntu):

cd $HOME
wget https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.sh
sudo sh cmake-3.12.0-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir

This is not integrated with the Ubuntu package management system but installs neatly to /usr/local and on my system then demonstrates the following:

andrew@ilium:~$ cmake --version | head -n1
cmake version 3.12.0

Subsequent removal is simply a matter of running the following single command in a Terminal window:

sudo rm -rfv /usr/local/bin/{cmake,cpack,ccmake,cmake-gui,ctest} \
             /usr/local/doc/cmake \
             /usr/local/man/man1/{ccmake.1,cmake.1,cmake-gui.1,cpack.1,ctest.1} \
             /usr/local/man/man7/cmake-* \
             /usr/local/share/cmake-3.12

This leaves your system clean and perhaps ready to install an even more modern version :).

References:

  • cmake: Get the Software The official download page for cmake. Some extra information concerning the .sh installer files.
Melebius
  • 11,800
andrew.46
  • 39,479
  • Thanks. I was looking for a ppa for ubuntu to use in travis-ci. I could build things myself for a local computer but I would like to avoid that in a CI server. Still, I got the answer I was looking: No reliable PPA available... – Juan Leni Sep 05 '17 at 22:50
  • There are a few more files to remove. Find them using find /usr/local -name '*cmake*' -o -name '*cpack*' -o -name '*ctest*'. – Melebius Jul 08 '19 at 12:27