[CMAKE] Enable clang-tidy
Summary:
This diff enables running clang-tidy at build time.
The checks are defined in the src/.clang-tidy file, and apply to every
subdirectories as well. For now, a single check is enabled to replace
boost::lexical_cast<std::string> with std::to_string (see
https://releases.llvm.org/8.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/boost-use-to-string.html).
This check should never trigger since D5136 removes
boost::lexical_cast, and our libraries are not using boost.
Depends on D5136.
Test Plan:
Pre-requisite: with no clang-tidy installed:
cmake -GNinja ..
Check that cmake returns an error because it fails to find clang-tidy.
cmake -GNinja .. -DENABLE_CLANG_TIDY=OFF ninja
Should return no error.
Install clang-tidy version >= 8.
cmake -GNinja .. ninja check-all bitcoin-bench
Add a boost::lexical_cast<std::string> case in any bitcoin-abc source
file, then run ninja again. Check that clang-tidy applied the fix and
replaced it with std::to_string.
Note: it seems that clang-tidy does not always replace, but sometimes
only outputs the warning.
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D5138