The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

50 lines
2.6 KiB

2 months ago
  1. find_program(CLANG_TIDY clang-tidy)
  2. if(NOT CLANG_TIDY)
  3. message(STATUS "Did not find clang-tidy, target tidy is disabled.")
  4. else()
  5. message(STATUS "Found clang-tidy, use \"make tidy\" to run it.")
  6. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Matches "Clang" and "AppleClang"
  7. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5)
  8. message(STATUS "Please enable readability-redundant-member-init (disabled due to #32966)")
  9. endif()
  10. endif()
  11. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  12. set(CLANG_TIDY_CHECKS "*")
  13. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-llvm-header-guard")
  14. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-llvm-include-order")
  15. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-llvm-namespace-comment")
  16. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-readability-else-after-return")
  17. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-misc-macro-parentheses")
  18. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-clang-analyzer-alpha.core.CastToStruct")
  19. # Modernize
  20. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-modernize-raw-string-literal")
  21. # CPP Core Guidelines
  22. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-cppcoreguidelines-pro-bounds-array-to-pointer-decay")
  23. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-cppcoreguidelines-pro-bounds-constant-array-index")
  24. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-cppcoreguidelines-pro-bounds-pointer-arithmetic")
  25. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-cppcoreguidelines-pro-type-member-init") # as of https://llvm.org/bugs/show_bug.cgi?id=31039
  26. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-cppcoreguidelines-pro-type-reinterpret-cast")
  27. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-cppcoreguidelines-pro-type-vararg")
  28. # Google
  29. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-google-readability-namespace-comments")
  30. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-google-readability-braces-around-statements,-readability-braces-around-statements")
  31. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-google-readability-todo")
  32. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-google-runtime-int")
  33. set(CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS},-google-runtime-references")
  34. set(CLANG_TIDY_CHECKS "-checks='${CLANG_TIDY_CHECKS}'")
  35. #message(STATUS "Enabled checks for clang-tidy: ${CLANG_TIDY_CHECKS}")
  36. endif()
  37. find_program(CLANG_FORMAT clang-format)
  38. if(NOT CLANG_FORMAT)
  39. message(STATUS "Did not find clang-format, target format is disabled.")
  40. else()
  41. message(STATUS "Found clang-format, use \"make format\" to run it.")
  42. add_custom_target(format
  43. COMMAND find ./ -iname "*.h" -o -iname "*.tpp" -o -iname "*.cpp" | xargs ${CLANG_FORMAT} -style=file -i -verbose
  44. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/
  45. )
  46. endif()