linting_build.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. if(UA_ENABLE_STATIC_ANALYZER STREQUAL MINIMAL OR UA_ENABLE_STATIC_ANALYZER STREQUAL REDUCED OR UA_ENABLE_STATIC_ANALYZER STREQUAL FULL)
  2. # cpplint just gives warnings about coding style
  3. find_program(CPPLINT_EXE NAMES "cpplint")
  4. if(CPPLINT_EXE)
  5. set(CMAKE_C_CPPLINT "${CPPLINT_EXE};--quiet")
  6. set(CMAKE_CXX_CPPLINT "${CPPLINT_EXE};--quiet")
  7. endif()
  8. endif()
  9. if(UA_ENABLE_STATIC_ANALYZER STREQUAL REDUCED OR UA_ENABLE_STATIC_ANALYZER STREQUAL FULL)
  10. # clang-tidy has certain warnings as errors
  11. find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
  12. if(CLANG_TIDY_EXE)
  13. set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXE};-p=compile_commands.json")
  14. set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-p=compile_commands.json")
  15. endif()
  16. elseif(UA_ENABLE_STATIC_ANALYZER STREQUAL FULL)
  17. # cppcheck provides just warnings but checks "all" (for now) - huge CPU impact
  18. find_program(CPPCHECK_EXE NAMES "cppcheck")
  19. if(CPPCHECK_EXE)
  20. set(CMAKE_C_CPPCHECK "${CPPCHECK_EXE};--project=compile_commands.json;--enable=all;--inconclusive;--inline-suppr;\
  21. --suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck-suppressions.txt;-D__GNUC__;-i ${PROJECT_SOURCE_DIR}/build")
  22. set(CMAKE_CXX_CPPCHECK "${CPPCHECK_EXE};--project=compile_commands.json;--enable=all;--inconclusive;--inline-suppr;\
  23. --suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck-suppressions.txt;-D__GNUC__;-i ${PROJECT_SOURCE_DIR}/build")
  24. endif()
  25. # "include what you use" requires additional configuration - ignore for now
  26. find_program(IWYU_EXE NAMES "iwyu")
  27. if(IWYU_EXE)
  28. #set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${IWYU_EXE}")
  29. #set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU_EXE}")
  30. endif()
  31. endif()