LoginSignup
4
2

More than 3 years have passed since last update.

CMake Error: Could not find CMAKE_ROOT !!! を回避

Last updated at Posted at 2020-07-29

概要

cmake のアップデートの際に発生したエラーとその対処について記します。

cmake アップデート

cmake を 3.5 から 3.18 にアップデートしたい。
こちらのサイト https://cmake.org/download/ からソースファイルをダウンロードして、ビルドしました。具体的には

$ wget https://cmake.org/files/v3.18/cmake-3.18.0.tar.gz
$ tar xvf cmake-3.18.0.tar.g
$ ./configure --prefix=[インストールする先]
$ make
$ make install

やっていることの説明:

  • ./configure で Makefile を作成
  • make でソースコードをコンパイル
  • make install で make で生成されたバイナリファイルを[インストールする先]に保存

発生したエラー

つぎのエラーが発生しました。

$ cmake --version
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/home/name/ubuntu16/share/cmake-3.5
cmake version 3.5.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

これは前のバージョンの cmake を消していないことによるものっぽい...。
Module directory がないと言われているディレクトリを覗いてみると

$ ls /home/name/ubuntu16/share/
/home/name/ubuntu16/share/cmake-3.18

なるほど、
新しくインストールしたものしかないのに、前のファイルを見ようとしているようです。
新しくインストールしたファイルを見よと教えてあげればよさそう。

対応

CMAKE_ROOT を明示的に示すために、.bash_profile に次を追記しました

export CMAKE_ROOT=/home/name/ubuntu16/share/cmake-3.18

この対処法であっているのかわかりませんが、インストールした cmake のバージョンに合わせて最後は変えれば良いかと思います。

$ source .bash_profile 

で .bash_profile を読み込むと

$ cmake --version
cmake version 3.18.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

これで無事アップデートできたことが確認できました。

参考

cmake とはなんぞやという疑問にはこの記事はわかりやすかったです
https://qiita.com/turenar/items/922a845cfc9350b0eece#fn2

cmake アップデートはこの記事を参考にしました
https://qiita.com/koara-local/items/9d01c6bb9dd93563b7c6

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2