# additional target to perform clang-tidy run, requires clang-tidy

if (NOT CLANG_TIDY_EXECUTABLE)
  find_program(CLANG_TIDY_EXECUTABLE clang-tidy /usr/bin /usr/local/bin /bin)
endif()

if (CLANG_TIDY_EXECUTABLE)
	message(STATUS "CLANG_TIDY_EXECUTABLE: ${CLANG_TIDY_EXECUTABLE}")
	file(GLOB_RECURSE LEDCTLEMUD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
	file(GLOB_RECURSE LEDCTLEMUD_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)

	list(APPEND LEDCTLEMUD_INCLUDE_DIRECTORIES "-I${CMAKE_CURRENT_SOURCE_DIR}")

	add_custom_target(
		ledctlemud-clang-tidy
		COMMAND ${CLANG_TIDY_EXECUTABLE}
		${LEDCTLEMUD_SOURCE_FILES}
		-checks=-*,clang-analyzer-*,bugprone-*,misc-*,hicpp-*,performance-*
		-export-fixes='${CMAKE_CURRENT_BINARY_DIR}/clang-tidy-fixes.dat'
		--
		-std=c++14
		${LEDCTLEMUD_INCLUDE_DIRECTORIES}
		)
else ()
	message(FATAL_ERROR "No clang-type executable is found.")
endif (CLANG_TIDY_EXECUTABLE)
