34
28

More than 5 years have passed since last update.

Linuxに特定のバージョンのcmakeをインストール

Last updated at Posted at 2018-10-11

以前、自分用に書いたメモをさらします。

  • 環境
    • Ubuntu16.04 LTS
    • cmake-3.7.2のインストール

CMAKEのインストール手順

既存のcmake削除

もし、すでに別のバージョンのcmakeが入っていれば以下のコマンドで削除します。

$ sudo apt remove cmake

ダウンロード

まずは公式サイトから特定のバージョンのcmakeをダウンロードします。

ここで下にスクロールすると"Older Releases"が見つかるのでそのリンクからとびます。(下図)

cmake_older_releases.png

以下のようなページに繋がるとおもうのでそこから好きなバージョンを選択して進みます。
image.png

Linuxにダウンロードする際は対応のものを選んでダウンロードします。
ここではシェルスクリプト(cmake-3.7.2-Linux-x86_64.sh)のみをダウンロードしてみます。
ちなみに後でわかる通りこのシェルスクリプトは.tar.gzファイルを解凍したものを生成するので.tar.gzファイルをダウンロードしても問題ないです。

download_files.png

$ chmod +x cmake-3.7.2-Linux-x86_64.sh                             # 実行権限を付与
$ sudo ./cmake-3.7.2-Linux-x86_64.sh                               # 実行してディレクトリを生成する
...
--続きます--                                                        # qを押す
Do you accept the license? [yN]: 
y                                                                  # y
By default the CMake will be installed in:
  "/home/pollenjp/Desktop/cmake-3.7.2-Linux-x86_64"                # (デフォルトでは実行したディレクトリに生成される)
Do you want to include the subdirectory cmake-3.7.2-Linux-x86_64?
Saying no will install in: "/home/pollenjp/Desktop" [Yn]: 
y                                                                  # y

Using target directory: /home/pollenjp/Desktop/cmake-3.7.2-Linux-x86_64
Extracting, please wait...

Unpacking finished successfully

引き続き以下を実行

$ sudo mv cmake-3.7.2-Linux-x86_64 /opt                     # 生成したディレクトリを/opt以下に移動(移動しなくてもよい)
$ sudo ln -s /opt/cmake-3.7.2-Linux-x86_64/bin/* /usr/bin   # シンボリックリンクを生成して完了

確認

$ cmake --version
cmake version 3.7.2

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

参考

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