You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 with cmake --build <build directory> --target <target name>.
To disable using cmake_format to format CMake files, set the cmake option FORMAT_SKIP_CMAKE to a truthy value, e.g. by invoking CMake with -DFORMAT_SKIP_CMAKE=YES, or enabling the option when adding the dependency (recommended).
To disable using clang_format to format clang-supported files, set the cmake option FORMAT_SKIP_CLANG to a truthy value, e.g. by invoking CMake with -DFORMAT_SKIP_CLANG=YES, or enabling the option when adding the dependency (recommended).
To specify a extra arguments for cmake-format, use the cmake option CMAKE_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 when adding the dependency (recommended).
This package supports optional parameters that you can specify in the CPM.cmake OPTIONS argument.
CPMAddPackage(
NAMEFormat.cmakeVERSION1.8.2GITHUB_REPOSITORYTheLartians/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.