include(color_print)
include(code_refactor)

macro(diagnostic)
  get_filename_component(libname ${CMAKE_CURRENT_SOURCE_DIR} NAME)
  if(NOT TARGET ${libname})
    set(libname ${ARGN})
  else()
    if(code_format)
      clang_format(${libname})
    endif()
  endif()

  if(debug)
    color_print(cyan "--> ${libname}: ")
    get_target_property(list ${libname} INCLUDE_DIRECTORIES)
    message(STATUS "${libname} target INCLUDE_DIRECTORIES list: -> ${list}")
    get_target_property(list ${libname} COMPILE_DEFINITIONS )
    message(STATUS "${libname} target COMPILE_DEFINITIONS list: -> ${list}")
    get_target_property(list ${libname} LINK_LIBRARIES)
    message(STATUS "${libname} target LINK_LIBRARIES list: -> ${list}")
    get_target_property(list ${libname} COMPILE_OPTIONS)
    message(STATUS "${libname} target COMPILE_OPTIONS list: -> ${list}")
  else()
    color_print(cyan "--> ${libname}: ")
  endif()
endmacro()

macro(target_diagnostic taget)
  if(NOT TARGET ${target})
    message("--> ${target} is not a target!")
  endif()

  if(debug)
    color_print(cyan "--> ${target}: ")
    get_target_property(list ${target} INCLUDE_DIRECTORIES)
    message(STATUS "${target} target INCLUDE_DIRECTORIES list: -> ${list}")
    get_target_property(list ${target} COMPILE_DEFINITIONS )
    message(STATUS "${target} target COMPILE_DEFINITIONS list: -> ${list}")
    get_target_property(list ${target} LINK_LIBRARIES)
    message(STATUS "${target} target LINK_LIBRARIES list: -> ${list}")
    get_target_property(list ${target} COMPILE_OPTIONS)
    message(STATUS "${target} target COMPILE_OPTIONS list: -> ${list}")
  else()
    color_print(cyan "--> ${target}: ")
  endif()
endmacro()
