Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,27 @@ target_include_directories(antimicrox PUBLIC
${SDL2_INCLUDE_DIRS}/SDL2
)

option(ENABLE_CLANG_TIDY "Run clang-tidy during C++ compilation." OFF)
option(ENABLE_CLANG_TIDY_FIXES "Enable clang-tidy automatic fixes when running during compilation." OFF)
set(CLANG_TIDY_EXECUTABLE "clang-tidy" CACHE STRING "Path to the clang-tidy executable")
set(CLANG_TIDY_CHECKS "modernize-*,bugprone-*,performance-*,-clang-analyzer-*" CACHE STRING "clang-tidy checks list")

if(ENABLE_CLANG_TIDY AND NOT COMPILER_IS_MSVC)
set(_clang_tidy_command "${CLANG_TIDY_EXECUTABLE};-checks=${CLANG_TIDY_CHECKS}")
if(ENABLE_CLANG_TIDY_FIXES)
list(APPEND _clang_tidy_command "-fix" "-fix-errors")
endif()
set(CMAKE_CXX_CLANG_TIDY "${_clang_tidy_command}")
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
set(CMAKE_LANG_CLANG_TIDY "${_clang_tidy_command}")
endif()
message(STATUS "clang-tidy enabled: ${_clang_tidy_command}")
if(ENABLE_CLANG_TIDY_FIXES)
message(STATUS "clang-tidy automatic fixes are enabled.")
endif()
message(STATUS "Use -DCMAKE_EXPORT_COMPILE_COMMANDS=1 to generate a compile commands database for manual clang-tidy runs.")
endif()

###############################
# INSTALL
###############################
Expand Down
Loading