Update cmake

This is the best methood if you have environment to build cmake from source code

wget https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6.tar.gz

tar -xzf cmake-3.31.6.tar.gz
cd cmake-3.31.6

./bootstrap
make -j$(nproc)
sudo make install

Now check cmake version

cmake --version

Method 2: Download the Official Binary

This is the easiest and safest method

  • Remove old version (optional)

    sudo apt remove cmake
    
  • Download the required version

    wget https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-linux-x86_64.tar.gz
    
  • Extract

    tar -xzf cmake-3.31.6-linux-x86_64.tar.gz   
    
  • Move it

    sudo mv cmake-3.31.6-linux-x86_64 /opt/cmake-3.31.6
    
  • Create symbolic links

    sudo ln -sf /opt/cmake-3.31.6/bin/cmake /usr/local/bin/cmake
    sudo ln -sf /opt/cmake-3.31.6/bin/ctest /usr/local/bin/ctest
    sudo ln -sf /opt/cmake-3.31.6/bin/cpack /usr/local/bin/cpack
    
  • verify

    cmake --version
    

©2023-2024 rculock.com