Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kbenzie/git-cmake-format
Standardise code formating for cmake projects with git and clang-format
https://github.com/kbenzie/git-cmake-format
Last synced: about 2 months ago
JSON representation
Standardise code formating for cmake projects with git and clang-format
- Host: GitHub
- URL: https://github.com/kbenzie/git-cmake-format
- Owner: kbenzie
- License: unlicense
- Created: 2014-08-28T21:59:27.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T20:48:53.000Z (over 6 years ago)
- Last Synced: 2024-02-01T20:12:25.158Z (5 months ago)
- Language: CMake
- Homepage:
- Size: 25.4 KB
- Stars: 55
- Watchers: 6
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Lists
- awesome-cmake - git-cmake-format - Integrate clang-format into your CMake project hosted in a git repository. [```[LICENSE]```](https://github.com/kbenzie/git-cmake-format/blob/master/license.txt) (Other)
README
# git-cmake-format
This project aims to provide a quick and easy way to integrate clang-format into
your CMake project hosted in a git repository, it consists of three elements.* `CMakeLists.txt` provides the custom `format` target
* `git-pre-commit-hook` blocks commits of unformatted C/C++ files
* `git-cmake-format.py` is called by the `format` target or the `pre-commit`
hook, it queries git for edited files, then block the commit or formats the
sources## Dependencies
There are three dependencies:
* `git`
* `python` 2.7+
* `clang-format`## Usage
To make use of this project you can either add it as a submodule to your
existing project, or copy the files into your repository. Now add the following
to your `CMakeLists.txt`.
```
add_subdirectory(/path/to/git-cmake-format)
```Next you can generate your build system, assuming the required dependencies are
available on your path.```
cd build
cmake ..
```The installation of the `pre-commit` hook is done at CMake time during the
generation of the build system, if you have followed these steps it is already
installed at `/path/to/your/project/.git/hooks/pre-commit`.### Options
It is possible to specify the path to any of the executables this project
depends upon using the following CMake variables.* `GCF_GIT_PATH:STRING=/path/to/git`
* `GCF_PYTHON_PATH:STRING=/path/to/python`
* `GCF_CLANGFORMAT_PATH:STRING=/path/to/clang-format` defaults to `clang-format`It is also possible to set the `-style=` command line argument for
`clang-format` with the following options, the default is `file`* `GCF_CLANGFORMAT_STYLE:STRING=WebKit`