mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-18 08:51:29 +00:00
101cdea022
clang-tidy performs static analysis over the compilation unit, producing more comprehensive compile warnings than are normally generated by the compiler. For example, it will trace branches in a function to find the exact conditions in which a null dereference can occur. Note that this produces an absurd amount of warnings for our existing C code, and significantly slows compile times. It is pretty effective at its job though. I think it would be good to turn on by default for upcoming C++ code.
21 lines
731 B
CMake
21 lines
731 B
CMake
find_program(CLANG_TIDY clang-tidy)
|
|
|
|
# Note: Apple Clang does not ship with clang tools. If you want clang-tidy on
|
|
# macOS, it's best to install the Homebrew llvm bottle and set CLANG_TIDY
|
|
# in your build directory. The llvm package is keg-only, so it will not
|
|
# collide with Apple Clang.
|
|
|
|
function(target_set_default_clang_tidy target lang checks)
|
|
if("${CLANG_TIDY}" STREQUAL "CLANG_TIDY-NOTFOUND")
|
|
return()
|
|
endif()
|
|
|
|
get_target_property(c_clang_tidy_prop SRB2SDL2 C_CLANG_TIDY)
|
|
if(NOT ("${c_clang_tidy_prop}" STREQUAL "c_clang_tidy_prop-NOTFOUND"))
|
|
return()
|
|
endif()
|
|
|
|
set_target_properties("${target}" PROPERTIES
|
|
${lang}_CLANG_TIDY "${CLANG_TIDY};-checks=${checks}"
|
|
)
|
|
endfunction()
|