CMake ファイルのフォーマット

cmake-formatツールとローカルの.cmake-format.py 、または.json 設定ファイルを使用すると、CMakeファイル内の任意のテキストをフェンスのペアで保護しないようにフォーマットすることができます。ツールをインストールし、Qt Creator にインストールした場所を伝える必要があります。

ファイル保存時に CMake ファイルを自動的にフォーマットするには:

  1. Preferences>CMake >Formatter を選択します。

    CMake環境設定のフォーマッタタブ

  2. CMakeFormat command に、cmake-format.exe へのパスを入力します。
  3. 保存時に CMake ファイルを自動的にフォーマットするには、Automatic formatting on file save を選択します。

    ファイル保存時にこの設定を一時的に無効にするには、FileSave Without Formatting を選択します。

  4. Restrict to MIME types に、フォーマットするファイルの MIME タイプをセミコロンで区切って追加します。デフォルト値のtext/x-cmake は、CMake ファイルをフォーマットします。フィールドが空の場合、すべてのファイルがフォーマットされます。
  5. 現在のプロジェクトに属する CMake ファイルのみをフォーマットするには、Restrict to files contained in the current project を選択します。

How To: Build with CMake」、「Edit MIME types」、「CMake」も参照してください

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.