LoginSignup
2
2

More than 1 year has passed since last update.

CMake【インストール編】

Last updated at Posted at 2022-01-20

CMakeについて

C/C++には古くよりgcc/g++コマンドやmakefile, autoconfなどのビルド方法があります
これらはLinuxがベースになっていてWindows/Macでは使えなかったり、それぞれのプラットフォームに依存があったりします
また、ビルドする際にルートディレクトリにファイルが出力され、gitの差分が多く出たりもします

CMakeはこれらの問題を(書き方次第ではあるが)解決してくれるツールです

CMakeのインストール

CMakeはWin/Mac/Linux向けのツールです
最新版のインストール方法について説明します(執筆時点の最新3.22.1)
また、2021年辺りよりarm64向けのインストーラも配布されるようになりました

Windows

32bit版Windows:[Windows i386 Installer]の~.msiをダウンロードして実行
64bit版Windows:[Windows x64 Installer]の~.msiをダウンロードして実行
無題.png

Mac

macOS 10.13以降:[macOS 10.13 or later]の~.dmgをダウンロードして実行
それ以前    :[macOS 10.10 or later]の~.dmgをダウンロードして実行
無題2.png

Homebrew

brew install cmake

Ubuntu-x86_64

Intel CPU向けのインストール方法

既にapt install cmakeされている場合は以下を実行してください

sudo apt purge cmake
sudo rm -r /usr/share/cmake
sudo rm -r /usr/share/cmake-3.xx // xxはインストールされているバージョン番号
cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-x86_64.sh
./cmake-3.22.1-linux-x86_64.sh
sudo mv cmake-3.22.1-linux-x86_64 /opt
sudo ln -s /opt/cmake-3.22.1-linux-x86_64/bin/* /usr/bin
rm cmake-3.22.1-linux-x86_64.sh

Ubuntu-aarch64

JetsonなどARM64向けのインストール方法

既にapt install cmakeされている場合は以下を実行してください

sudo apt purge cmake
sudo rm -r /usr/share/cmake
sudo rm -r /usr/share/cmake-3.xx // xxはインストールされているバージョン番号
cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-aarch64.sh
./cmake-3.22.1-linux-aarch64.sh
sudo mv cmake-3.22.1-linux-aarch64 /opt
sudo ln -s /opt/cmake-3.22.1-linux-aarch64/bin/* /usr/bin
rm cmake-3.22.1-linux-aarch64.sh

ソースコードビルド

Raspberry PiなどARM32だとこのインストール方法になります
※スゴイ時間かかります

cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1.tar.gz
tar xvf cmake-3.22.1.tar.gz
cd cmake-3.22.1
./bootstrap && make && sudo make install

以上、各OS向けのインストール方法でした
次回は実際にCMakeを書いていきます

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