diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-29 17:16:22 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-29 17:16:22 +0100 |
| commit | 4fa6821e0645ff61a9380cd090abff472205c630 (patch) | |
| tree | bd95f13b2dc0bd9692681f50c365d2914a520bfe /CMakeLists.txt | |
| parent | e5180acf5f2dfac788e8c12886095ed1ac66fae5 (diff) | |
| download | nihil-4fa6821e0645ff61a9380cd090abff472205c630.tar.gz nihil-4fa6821e0645ff61a9380cd090abff472205c630.tar.bz2 | |
add clang-tidy support
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 23 |
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) |
