cmake: Add optional clang-tidy integration
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.