- Notifications
You must be signed in to change notification settings - Fork27
💅 Stylize your code! Automatic clang-format and cmake-format targets for CMake.
License
TheLartians/Format.cmake
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
clang-format and cmake-format for CMake
Format.cmake adds three additional targets to your CMake project.
formatShows which files are affected by clang-formatcheck-formatErrors if files are affected by clang-format (for CI integration)fix-formatApplies 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).
UsingCPM.cmake (recommended)
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")
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}")
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)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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.
