43

This question already has an answer here:

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?

marked as duplicate by Eliah Kagan, Zanna, karel, Kulfy, Fabby Jul 23 at 20:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

45

Warning -- Do not do step 2 if you have 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 binaries
    • In my case cmake-3.6.2-Linux-x86_64.sh is sufficient copy the binary to /opt/
  4. chmod +x /opt/cmake-3.*your_version*.sh (chmod makes the script executable)
  5. sudo bash /opt/cmake-3.*your_version.sh* (you'll need to press y twice)

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

  6. sudo ln -s /opt/cmake-3.*your_version*/bin/* /usr/local/bin

    Test your results with cmake --version

  • 4
    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 '16 at 6:15
  • 10
    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. – sempaiscuba Jul 28 '17 at 0:18
  • 7
    ROS... "Robot Operating System"? – user1122069 Dec 4 '17 at 1:38
  • 4
    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 '18 at 15:15
  • 3
    i did all that but once i type cmake --version it says command Cmake not found :( – DINA TAKLIT Oct 5 '18 at 12:09
21

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
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
  • 3
    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" ? – Timothy Swan Dec 25 '17 at 20:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.