金子邦彦研究室インストールWindows の種々のソフトウェア(インストール)CMake のインストール(ソースコード,Build Tools for Visual Studio,cmake を使用)(Windows 上)

CMake のインストール(ソースコード,Build Tools for Visual Studio,cmake を使用)(Windows 上)

Ninja はビルドシステム.

前準備

Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022),Visual Studio 2022 のインストール(Windows 上)

サイト内の関連ページ

関連する外部ページ

Git のインストール(Windows 上)

Gitは,バージョン管理システム.ソースコードの管理や複数人での共同に役立つ.

サイト内の関連ページ

Windows での Git のインストール: 別ページ »で説明している.

関連する外部ページ

Git の公式ページ: https://git-scm.com/

CMake のインストール(Windows 上)

cmake のダウンロードページ: https://cmake.org/download/

CMake のインストール(ソースコード,Build Tools for Visual Studio,cmake を使用)(Windows 上)

  1. Windows で,コマンドプロンプト管理者として実行.

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. cmake のインストール

    cmake のオプションの 「Visual Studio 17 2022」のところは, 使用する Visual Studio のバージョンにあわせること. Visual Studio 2022 のときは,「Visual Studio 17 2022」. Visual Studio 2019 のときは,「Visual Studio 16 2019

    Flang を使用する予定がある場合には,次の操作を行う前に,別ページの手順を参考に Flang のインストールを終えておくこと.

    C:
    cd %HOMEPATH%
    rmdir /s /q CMake
    git clone --recursive https://github.com/Kitware/CMake
    cd CMake
    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_Fortran_COMPILER=flang-new ^
        -DCMAKE_INSTALL_PREFIX="C:/cmake"
    cmake --build. --config RELEASE
    cmake --build. --config RELEASE --target INSTALL
    

    エラーメッセージが出ていないことを確認

  3. Windowsシステム環境変数 Pathに,C:\cmake\bin次を追加することにより,パスを通す

    Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

    次のコマンドを実行

    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\cmake\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"