oranges_create_clang_tidy_target¶
include (OrangesClangTidy)
View the full docs for this module
.
oranges_create_clang_tidy_target ([CONFIG_FILE <file>] | [NO_DEFAULT_CONFIG] [EXTRA_ARGS <args...>] [COMPILE_COMMANDS_ONLY])
Creates a custom target named clang-tidy
that executes clang-tidy
over the entire source tree.
If the CLANGTIDY_OFF
variable is set to ON
, this function does nothing.
If the current CMake run will generate a CompileCommands.json file (supported by the Makefile and Ninja generators, and
enabled with the CMAKE_EXPORT_COMPILE_COMMANDS
option), then this file will be used for clang-tidy to process the
source tree. Otherwise, source files will be globbed under CMAKE_SOURCE_DIR
, unless the COMPILE_COMMANDS_ONLY
option is provided.
Note that all arguments are optional. Options:
CONFIG_FILE
May be specified to provide a custom
.clang-tidy
file to be used for running clang-tidy. If a relative path is given, it will be evaluated relative to the value ofCMAKE_CURRENT_LIST_DIR
when this function is called. If this argument is not specified, the value of theCLANGTIDY_CONFIG_FILE
variable will be used, unless theNO_DEFAULT_CONFIG
option is given. Providing this argument is equivalent to passingEXTRA_ARGS --config-file=<file>
.NO_DEFAULT_CONFIG
If this option is given, then the value of the
CLANGTIDY_CONFIG_FILE
variable will not be used as the.clang-tidy
file; instead, clang-tidy’s default behavior of searching for a.clang-tidy
in a parent directory of the current source file will be used.EXTRA_ARGS
Extra arguments that will be passed verbatim to the clang-tidy executable. If not specified, the value of the
CLANGTIDY_EXTRA_ARGS
variable will be used.COMPILE_COMMANDS_ONLY
If this option is given, then the
clang-tidy
target will only be created if the current CMake run will produce a CompileCommands.json, and otherwise this function will do nothing and raise no warnings or errors (aVERBOSE
message will be output).