THRIFT-4732:refine cmake scripts (#1688)
* add cmake support for clib and remove unused variables
* add targets for code analysis
* add wall to all compilers and add utf-8 options for msvc
diff --git a/build/cmake/StaticCodeAnalysis.cmake b/build/cmake/StaticCodeAnalysis.cmake
new file mode 100644
index 0000000..3356c76
--- /dev/null
+++ b/build/cmake/StaticCodeAnalysis.cmake
@@ -0,0 +1,9 @@
+find_package(ClangTools QUIET)
+if(clang-tidy_FOUND AND run-clang-tidy_FOUND AND NOT TARGET do_run_clang_tidy)
+ add_custom_target(
+ do_run_clang_tidy
+ COMMAND ClangTools::run-clang-tidy -clang-tidy-binary "$<TARGET_FILE:ClangTools::clang-tidy>" -p ${CMAKE_BINARY_DIR} "-quiet" > ./run-clang-tidy.txt
+ DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+endif()