From cf52adf62a46cc064c993deb1f342d88e83b9dd8 Mon Sep 17 00:00:00 2001 From: Michael Fabian Dirks Date: Sun, 19 Apr 2020 02:32:56 +0200 Subject: [PATCH] Update README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 1da06d9..a6d587e 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,26 @@ Add a `TARGETNAME_CLANG-TIDY` target to the project which runs clang-tidy on the * `REGEX `: Specify a regular expression by which to filter all sources of the given targets. Defaults to `\.(h|hpp|c|cpp)$`. * `VERSION `: Require a minimum Clang Toolset version to run clang-tidy. * `TARGETS [;[;...]]`: Specify on which targets clang-tidy is supposed to be run. + +# Example Usage +## Adding clang-format as a dependency and clang-tidy as a normal target +``` +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Clang/Clang.cmake") + include("Clang") + option(ENABLE_CLANG ON) + if(ENABLE_CLANG) + generate_compile_commands_json( + TARGETS ${PROJECT_NAME} + ) + clang_tidy( + TARGETS ${PROJECT_NAME} + VERSION 9.0.0 + ) + clang_format( + TARGETS ${PROJECT_NAME} + DEPENDENCY + VERSION 9.0.0 + ) + endif() +endif() +```