summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2017-05-02 23:49:17 +0200
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2017-05-04 17:39:23 +0200
commitd0c3e47d806ea3a25be2e7d190e479a6ccd8faa0 (patch)
tree2ad963e10da0e6410c677609541b27cc66d8a693 /CMakeLists.txt
parent894ff96c06e2598f88795458b70443b60cf4758a (diff)
downloadcmake-d0c3e47d806ea3a25be2e7d190e479a6ccd8faa0.tar.gz
clang-tidy: add option CMake_RUN_CLANG_TIDY
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 545177b6e4..4dcf2f0095 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -226,6 +226,20 @@ option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON)
mark_as_advanced(CMAKE_USE_FOLDERS)
+option(CMake_RUN_CLANG_TIDY "Run clang-tidy with the compiler." OFF)
+if(CMake_RUN_CLANG_TIDY)
+ if(CMake_SOURCE_DIR STREQUAL CMake_BINARY_DIR)
+ message(FATAL_ERROR "CMake_RUN_CLANG_TIDY requires an out-of-source build!")
+ endif()
+ find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
+ if(NOT CLANG_TIDY_COMMAND)
+ message(FATAL_ERROR "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
+ endif()
+ set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
+endif()
+configure_file(.clang-tidy .clang-tidy COPYONLY)
+
+
option(CMake_RUN_IWYU "Run include-what-you-use with the compiler." OFF)
if(CMake_RUN_IWYU)
find_program(IWYU_COMMAND NAMES include-what-you-use iwyu)