10

I'm trying to build a github project using cmake and I've been having a lot of trouble. I'm creating a build directory and calling cmake like so:

cd github_project_directory
mkdir build
cd build
cmake ..

This is the error I'm getting:

CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/bin
CMake Error: Error executing cmake::LoadCache(). Aborting.

I think there is a problem with how cmake is installed but I can't seem to figure it out. I've tried uninstalling and reinstalling but...I think it might have created even more trouble.

I'm on Ubuntu 14.04. Happy to provide more information as required.

Thank you!

  • Please edit your question to include the "project name" / a link to the git files. – Knud Larsen Mar 13 '18 at 22:27
6

I was getting the same error for anything cmake, including cmake --version, and the "reinstall cmake and cmake-data, then restart your shell" answers didn't work, so I tried manually setting CMAKE_ROOT to the path from dpkg -L cmake-data that contains the Modules directory.

export CMAKE_ROOT=/usr/share/cmake-3.5

That got cmake --version working, which revealed that I was somehow dealing with a cmake that reported itself as cmake 2.x, but a cmake-data package which created a cmake-3.5 folder for its resources.

It turned out that one of my PPAs was offering cmake 3.5 at the same package names that 14.04 uses for cmake 2.8 and, because of a dependency conflict, the cmake-data package had upgraded to 3.5, but the cmake package was getting held back at 2.8.

The following lines got things working for me:

sudo apt-get remove cmake cmake-data
sudo apt-get install cmake3 cmake3-data
| improve this answer | |
5

I had to re-install my cmake to correct this same error.

sudo apt-get remove cmake cmake-data
sudo -E add-apt-repository -y ppa:george-edison55/cmake-3.x
sudo -E apt-get update
sudo apt-get install cmake

Then be sure to re-source your rc.

. ~/.bashrc
| improve this answer | |
  • 1
    Running . ~/.bashrc solves the problem for me! – yuqli May 1 '19 at 23:09
0

You could use the version from pip

pip install cmake

➜ ~ cmake --version
cmake version 3.18.2
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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