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

cmake-formatツールと、ローカルの.cmake-format.py 、または.json 設定ファイルを使用することで、フェンスで囲まれていないCMakeファイル内の任意のテキストをフォーマットできます。このツールをインストールし、Qt Creator にインストール先を指定する必要があります。

ファイルの保存時に CMake ファイルの書式を自動的に整えるには:

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

    CMake の環境設定にある「フォーマッタ」タブ

  2. CMakeFormat command 」で、「cmake-format.exe 」へのパスを入力します。
  3. Automatic formatting on file save 」を選択すると、CMake ファイルを保存する際に自動的に書式設定が行われます。

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

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

「CMake でのビルド方法」、「 MIME タイプの編集、および「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.