diff --git a/.clang-tidy b/.clang-tidy index 02ccb2c..692fea7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -46,5 +46,5 @@ CheckOptions: - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic value: true WarningsAsErrors: '' -HeaderFilterRegex: '.*' +HeaderFilterRegex: '^(?!.*_deps).*' FormatStyle: file diff --git a/cmake/modules/FindClangTidy.cmake b/cmake/modules/FindClangTidy.cmake index e2be858..ff48003 100644 --- a/cmake/modules/FindClangTidy.cmake +++ b/cmake/modules/FindClangTidy.cmake @@ -20,7 +20,7 @@ # include_guard(GLOBAL) -option(CLANG_TIDY_ENABLE "Build with support for Include What You Use" OFF) +option(CLANG_TIDY_ENABLE "Build with support for clang-tidy" OFF) set(ClangTidy_VERBOSITY_LEVEL 3 CACHE STRING "Clang Tidy verbosity level (the higher the level, the more output)") @@ -134,6 +134,11 @@ function(enable_clang_tidy) return() endif() + if(NOT ClangTidy_FOUND) + _clang_tidy_log("clang-tidy not found") + return() + endif() + if(CLANG_TIDY_ARGS_CONFIG_FILE) if(NOT EXISTS ${CLANG_TIDY_ARGS_CONFIG_FILE}) message(FATAL_ERROR "clang-tidy: Config file '${CLANG_TIDY_ARGS_CONFIG_FILE}' does not exist") @@ -141,11 +146,11 @@ function(enable_clang_tidy) _clang_tidy_args_append("--config-file=${CLANG_TIDY_ARGS_CONFIG_FILE}") endif() - set(CMAKE_CXX_CLANG_TIDY "${ClangTidy_EXECUTABLE};-p=${CMAKE_BINARY_DIR};${_clang_tidy_args}" PARENT_SCOPE) + set(XYZ_CLANG_TIDY "${ClangTidy_EXECUTABLE};-p=${CMAKE_BINARY_DIR};${_clang_tidy_args}" CACHE INTERNAL "clang-tidy command") _clang_tidy_log(" Arguments: ${_clang_tidy_args}") _clang_tidy_log("Enabling clang-tidy - done") - _clang_tidy_log("CLANG_TIDY = ${CMAKE_CXX_CLANG_TIDY}") + _clang_tidy_log("XYZ_CLANG_TIDY = ${XYZ_CLANG_TIDY}") endfunction() if (CLANG_TIDY_ENABLE) diff --git a/cmake/xyz_add_object_library.cmake b/cmake/xyz_add_object_library.cmake index 7131f14..6868ecd 100644 --- a/cmake/xyz_add_object_library.cmake +++ b/cmake/xyz_add_object_library.cmake @@ -77,4 +77,8 @@ function(xyz_add_object_library) target_compile_definitions(${XYZ_NAME} PRIVATE ${XYZ_DEFINITIONS}) endif(XYZ_DEFINITIONS) + if(CLANG_TIDY_ENABLE AND ClangTidy_FOUND) + set_target_properties(${XYZ_NAME} PROPERTIES CXX_CLANG_TIDY "${XYZ_CLANG_TIDY}") + endif() + endfunction() diff --git a/cmake/xyz_add_test.cmake b/cmake/xyz_add_test.cmake index 85c4cf4..34fa56e 100644 --- a/cmake/xyz_add_test.cmake +++ b/cmake/xyz_add_test.cmake @@ -106,4 +106,8 @@ function(xyz_add_test) add_coverage(${XYZ_NAME}) endif() + if(CLANG_TIDY_ENABLE AND ClangTidy_FOUND) + set_target_properties(${XYZ_NAME} PROPERTIES CXX_CLANG_TIDY "${XYZ_CLANG_TIDY}") + endif() + endfunction()