Check current version
apt-cache policy cmake
# 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
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
apt-cache policy cmake
cmake --version
which cmake
This step only if you want to revert back
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