aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8bf5a42..8e8b131 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,11 +7,34 @@ project(nihil)
option(NIHIL_CONFIG "Build the nihil.config library" ON)
option(NIHIL_UCL "Build the nihil.ucl library" ON)
option(NIHIL_TESTS "Build nihil's unit tests" ON)
+option(NIHIL_TIDY "Run clang-tidy during build" ON)
set(CMAKE_CXX_STANDARD 26)
find_package(PkgConfig REQUIRED)
+# clang-tidy support
+find_program(CLANG_TIDY clang-tidy)
+
+if(NOT (CLANG_TIDY STREQUAL ""))
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+ file(GLOB_RECURSE NIHIL_SOURCES "*.cc" "*.ccm")
+ list(FILTER NIHIL_SOURCES EXCLUDE REGEX ${CMAKE_CURRENT_BINARY_DIR})
+
+ add_custom_target(tidy COMMAND
+ ${CLANG_TIDY} -config-file=${CMAKE_CURRENT_SOURCE_DIR}/clang-tidy.conf
+ -p=${CMAKE_CURRENT_BINARY_DIR}
+ ${NIHIL_SOURCES})
+
+ if(NIHIL_TIDY)
+ set(CMAKE_CXX_CLANG_TIDY
+ ${CLANG_TIDY};
+ -config-file=${CMAKE_CURRENT_SOURCE_DIR}/clang-tidy.conf;
+ )
+ endif()
+endif()
+
add_compile_options(-W)
add_compile_options(-Wall)
add_compile_options(-Wextra)