Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

💅 Stylize your code! Automatic clang-format and cmake-format targets for CMake.

License

NotificationsYou must be signed in to change notification settings

TheLartians/Format.cmake

Repository files navigation

Actions StatusActions Status

Format.cmake

clang-format and cmake-format for CMake

About

Format.cmake adds three additional targets to your CMake project.

  • format Shows which files are affected by clang-format
  • check-format Errors if files are affected by clang-format (for CI integration)
  • fix-format Applies clang-format to all affected files

To run the targets, invoke CMake withcmake --build <build directory> --target <target name>.

To disable usingcmake_format to format CMake files, set the cmake optionFORMAT_SKIP_CMAKE to a truthy value, e.g. by invoking CMake with-DFORMAT_SKIP_CMAKE=YES, or enabling the option whenadding the dependency (recommended).

To disable usingclang_format to format clang-supported files, set the cmake optionFORMAT_SKIP_CLANG to a truthy value, e.g. by invoking CMake with-DFORMAT_SKIP_CLANG=YES, or enabling the option whenadding the dependency (recommended).

To specify a extra arguments for cmake-format, use the cmake optionCMAKE_FORMAT_EXTRA_ARGS, e.g. by invoking CMake with-DCMAKE_FORMAT_EXTRA_ARGS="-c /path/to/cmake-format-config.{yaml,json,py}",or by enabling the option whenadding the dependency (recommended).

Demo

How to integrate

UsingCPM.cmake (recommended)

Basic configuration

Afteradding CPM.cmake, add the following line to the project'sCMakeLists.txt after callingproject(...).

include(cmake/CPM.cmake)CPMAddPackage("gh:TheLartians/Format.cmake@1.8.2")

Advanced configuration

This package supports optional parameters that you can specify in the CPM.cmakeOPTIONS argument.

CPMAddPackage(NAME Format.cmakeVERSION 1.8.2  GITHUB_REPOSITORY TheLartians/Format.cmakeOPTIONS# set to yes skip cmake formatting"FORMAT_SKIP_CMAKE NO"# set to yes skip clang formatting"FORMAT_SKIP_CLANG NO"# path to exclude (optional, supports regular expressions)"CMAKE_FORMAT_EXCLUDE cmake/CPM.cmake"# extra arguments for cmake_format (optional)"CMAKE_FORMAT_EXTRA_ARGS -c /path/to/cmake-format.{yaml,json,py}")

Using git submodules (not suited for libraries)

Run the following from the project's root directory.

git submodule add https://github.com/TheLartians/Format.cmake

In add the following lines to the project'sCMakeLists.txt after callingproject(...).

add_subdirectory(Format.cmake)

Dependencies

Format.cmake requiresCMake,clang-format,python 2.7 orpython 3, andcmake-format (optional).

About

💅 Stylize your code! Automatic clang-format and cmake-format targets for CMake.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors8


[8]ページ先頭

©2009-2025 Movatter.jp