oranges_enable_clangformat

include (OrangesClangFormat)

View the full docs for this module.

oranges_enable_clangformat (<target>
                           [POST_BUILD] [TARGET_NAME <targetName>]
                           [USE_FILE] | [STYLE <LLVM|Google|Chromium|Mozilla|WebKit>])

Adds rules to format <target>’s sources using clang-format.

The target’s sources are automatically detected using generator expressions.

Options:

POST_BUILD

If this flag is present, a post-build command will be added to <target> to invoke clang-format. Note that this may be used in conjunction with the TARGET_NAME option.

TARGET_NAME

If present, creates a custom target named <targetName> that executes clang-format to format <target>’s sources. Note that this may be used in conjunction with the POST_BUILD flag.

USE_FILE

If present, clang-format will search for a .clang-format file in the parent directories of each file being formatted. If this file cannot be found, formatting will be skipped. Usage of this flag is mutually exclusive with the STYLE option.

STYLE

Specify a default formatting style to use (instead of a custom .clang-format file).

If neither USE_FILE or STYLE are given, the value of the CLANGFORMAT_STYLE variable will be specified as the style for clang-format to use.

Cache variables

CLANGFORMAT_PROGRAM

Path to the clang-format executable. The environment variable with this name, if set, will initialize this variable.

CLANGFORMAT_STYLE

Default style to use for calls to oranges_enable_clangformat() that do not explicitly override this option. The environment variable with this name, if set, will initialize this variable.