myx-cmake-example-features/cmake/myx/lib/ColoredMessages.cmake
2022-10-06 15:22:57 +03:00

57 lines
1.8 KiB
CMake
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#[=======================================================================[.rst:
Обёртки для функции `message()`, которые в терминале UNIX
подсвечиают сообщения в зависимости от важности.
#]=======================================================================]
include_guard(GLOBAL)
if(DEFINED ENV{TERM} AND UNIX)
string(ASCII 27 Esc)
set(MyxColorReset "${Esc}[m")
set(MyxColorBold "${Esc}[1m")
set(MyxColorRed "${Esc}[31m")
set(MyxColorGreen "${Esc}[32m")
set(MyxColorYellow "${Esc}[33m")
set(MyxColorBlue "${Esc}[34m")
set(MyxColorMagenta "${Esc}[35m")
set(MyxColorCyan "${Esc}[36m")
set(MyxColorWhite "${Esc}[37m")
set(MyxColorBoldRed "${Esc}[1;31m")
set(MyxColorBoldGreen "${Esc}[1;32m")
set(MyxColorBoldYellow "${Esc}[1;33m")
set(MyxColorBoldBlue "${Esc}[1;34m")
set(MyxColorBoldMagenta "${Esc}[1;35m")
set(MyxColorBoldCyan "${Esc}[1;36m")
set(MyxColorBoldWhite "${Esc}[1;37m")
endif()
function(myx_message_fatal_error)
message(FATAL_ERROR ${MyxColorBoldRed}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_send_error)
message(SEND_ERROR ${MyxColorBoldRed}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_warning)
message(WARNING ${MyxColorRed}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_deprecation)
message(DEPRECATION ${MyxColorBoldMagenta}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_status)
message(STATUS ${MyxColorMagenta}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_notice)
message(${MyxColorBold}${ARGV}${MyxColorReset})
endfunction()
function(myx_message)
message(${MyxColorReset}${ARGV}${MyxColorReset})
endfunction()