24
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?

30
  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
  4. chmod +x /path/to/cmake-3.6.2-Linux-x86_64.sh (use your own file location here, but chmod makes the script executable)
  5. sudo /path/to/cmake-3.6.2-Linux-x86_64.sh (you'll need to press y twice)

    The script installs to /opt/cmake-3.6.2-Linux-x86_64 so in order to get the cmake command, make a symbolic link:

  6. sudo ln -s /opt/cmake-3.6.2-Linux-x86_64/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
  • Yep, but based on what I read on other forums, most users would rather avoid the potential confusion – Wolf Sep 25 '16 at 6:27
  • 7
    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
  • 4
    ROS... "Robot Operating System"? – user1122069 Dec 4 '17 at 1:38
  • 2
    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
8

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
1

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
    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

protected by Community Feb 20 '18 at 14:52

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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