LoginSignup
1
0

【Windows】Ninja 導入

Last updated at Posted at 2024-03-24

Ninja とは

Ninja とは、ビルドシステムの 1 種である。
Make よりも高レベルなビルドシステムによってビルドファイルを生成することで、高速なビルドを可能にしている。

前準備

Git のインストール

CMake のインストール

Build Tools for Visual Studio 2022 のインストール

Ninja のインストール

コマンドプロンプトを管理者として実行
image.png

以下のコマンドラインを実行

C:
cd %HOMEPATH%
rmdir /s /q ninja
git clone git://github.com/ninja-build/ninja.git
cd ninja
git checkout release
rmdir /s /q build
mkdir build
cd build
del CMakeCache.txt
cmake .. -G "Visual Studio 17 2022" -A x64 -T host=x64 ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DCMAKE_INSTALL_PREFIX="C:/ninja"
cmake --build . --config RELEASE
cmake --build . --config RELEASE --target INSTALL
.\Release\ninja_test.exe

エラーメッセージが出ていなければ OK
image.png

git clone で以下のエラーが発生する場合

C:\Users\**>git clone git://github.com/ninja-build/ninja.git
Cloning into 'ninja'...
fatal: unable to connect to github.com:
github.com[0: 20.27.177.113]: errno=Unknown error

Git ポートが制限されているために発生している。
よって、以下のコマンドラインを実行することで解消することができる。

git config --global url.https://github.com/.insteadOf git://github.com/

Ninja にパスを通す

コマンドプロンプトを管理者として実行
image.png

以下のコマンドラインを実行

powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\ninja\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
1
0
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
1
0