Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Forked from bmegli/CMake_3_20_Ubuntu_18_04.md
Created December 6, 2021 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasG77/fb4d2bce1516e06503cfcf53efe8bfdb to your computer and use it in GitHub Desktop.
Save ThomasG77/fb4d2bce1516e06503cfcf53efe8bfdb to your computer and use it in GitHub Desktop.
CMake 3.20 in Ubuntu 18.04 (reversible way)

Motivatation

  • modern CMake is required for building a lot of new software
  • CMake is dependency for many packages (e.g. ROS related)
  • we don't want to remove CMake (which would remove packages that depend on it)
  • we want safe procedure to update CMake that can be reversed easily

Current version in OS

Check current version

apt-cache policy cmake

Build CMake 3.20

# get and build CMake
wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0.tar.gz
tar -zvxf cmake-3.20.0.tar.gz
cd cmake-3.20.0
./bootstrap
make -j8

Install as package

So that we can easily remove it later

sudo apt-get install checkinstall
# this will take more time than you expect
sudo checkinstall --pkgname=cmake --pkgversion="3.20-custom" --default
# reset shell cache for tools paths
hash -r

Verify installation

apt-cache policy cmake
cmake --version
which cmake

Uninstall

This step only if you want to revert back

  • we don't want to remove cmake
  • this could cause removal of packages that depend on it (e.g. ROS)
  • instead we switch back to previous version
# idenitfy version of interest
apt-cache policy cmake
# switch to different version (from policy above)
apt-get install cmake=VERSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment