CMake Error: Could not find CMAKE_ROOT?

Solution 1:

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

Solution 2:

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