113
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.6.0 or higher is required.  You are running version 3.5.1
-- Configuring incomplete, errors occurred!

I know Ubuntu uses stable releases that it can support, but some repos require later versions of cmake. I want to overwrite the old cmake with the later version of cmake, but the common PPA doesn't carry the cmake I need. How can I upgrade cmake to use the needed version without conflicts with the older version?

0

3 Answers 3

152

Warning -- Do not do step 2 if you have Robot Operating System (ROS) installed

  1. Check your current version with:

    cmake --version
    
  2. Uninstall it with:

    sudo apt remove cmake
    
  3. Visit https://cmake.org/download/ and download the latest bash script.

    • In my case cmake-3.6.2-Linux-x86_64.sh is sufficient.
  4. Copy the script to /opt/.

  5. Make the script executable:

    chmod +x /opt/cmake-3.*your_version*.sh
    
  6. Change to desired installation directory (to /opt/ for example)

    • As of cmake 3.10.2 the installer no longer seems to install to /opt by default
  7. Run:

    sudo bash /opt/cmake-3.*your_version*.sh
    

    You will need to press y twice.

  8. The script installs the binary to /opt/cmake-3.*your_version* so in order to get the cmake command, make a symbolic link:

    sudo ln -s /opt/cmake-3.*your_version*/bin/* /usr/local/bin
    
  9. Test your results with:

    cmake --version
    
22
  • 8
    Don't think you need to uninstall the old cmake because /usr/local/bin is ahead of /usr/bin in PATH. So once you make the symlink in your last step, the cmake command will call your new cmake instead of the old one.
    – edwinksl
    Sep 25, 2016 at 6:15
  • 19
    As observed by Matt, IF YOU ARE A ROS USER DO NOT RUN "REMOVE CMAKE" Running this command will remove the current cmake version but will also remove parts of your ROS distribution, breaking everything and forcing you to re-install EVERYTHING related to ROS. A warning should be added to this command, or at the very least the leading answer should include a way to update cmake, rather than remove-and-replace. Jul 28, 2017 at 0:18
  • 17
    ROS... "Robot Operating System"? Dec 4, 2017 at 1:38
  • 11
    As of cmake 3.10.2 the installer no longer seems to install to /opt by default but rather to the current directory, so step 6 needs to be amended accordingly by the user.
    – JorgeGT
    Feb 14, 2018 at 15:15
  • 6
    i did all that but once i type cmake --version it says command Cmake not found :( Oct 5, 2018 at 12:09
58

In the new version of cmake (ex: 3.9.6), to install, download tar file from https://cmake.org/download/. Extract the downloaded tar file and then:

cd $CMAKE_DOWNLOAD_PATH
./configure
make
sudo make install
4
  • 3
    I like this solution because it is arguably the purest way to solve the problem. (Just build the software.) No mucking around with PPAs or anything. Thanks! Jun 1, 2020 at 4:09
  • 1
    This is a self-consistent solution. It works for me.
    – Yuanhui
    Jan 20, 2021 at 8:55
  • I did this to update to 3.17 but after sudo make install I get this CMake Error: Could not find CMAKE_ROOT !!! CMake has most likely not been installed correctly. Modules directory not found in /usr/local/share/cmake-3.16 cmake version 3.16.3 May 6, 2021 at 20:26
  • 2
    First had to install OpenSSL to make it work: "sudo apt-get install libssl-dev"
    – Matt
    Jan 8, 2022 at 19:11
2

I would like to follow your advice Wolf, but the script don't install the prog. So i just creat the folder but doesn't show like installed when i do

 cmake --version 

I find a other way peraps more easy :

sudo -E add-apt-repository -y ppa:george-edison55/cmake-3.x
sudo -E apt-get update
sudo apt-get install cmake
2
  • 5
    I tried this and it updated from 2.x to 3.2.2, but my build script still says "CMake 3.5.1 or higher is required." Is it possible to specify the add-apt-repository to be an even later version than 3.x, say something like "3.5.x" ? Dec 25, 2017 at 20:09
  • 1
    Tis limited to version 3.5.2-2 while current distributes support 3.10.2
    – Salem F
    Feb 26, 2020 at 14:49

Not the answer you're looking for? Browse other questions tagged .