myx/MyxCMake/lib/ColoredMessages.cmake

57 lines
1.8 KiB
CMake
Raw Permalink Normal View History

2022-10-01 13:42:36 +00:00
#[=======================================================================[.rst:
Обёртки для функции `message()`, которые в терминале UNIX
2023-07-30 07:53:43 +00:00
подсвечивают сообщения в зависимости от важности.
2022-10-01 13:42:36 +00:00
#]=======================================================================]
2022-09-28 23:46:29 +00:00
include_guard(GLOBAL)
if(DEFINED ENV{COLORTERM} AND UNIX)
2022-09-28 23:46:29 +00:00
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()
2022-10-01 13:42:36 +00:00
function(myx_message_fatal_error)
2022-09-28 23:46:29 +00:00
message(FATAL_ERROR ${MyxColorBoldRed}${ARGV}${MyxColorReset})
endfunction()
2022-10-01 13:42:36 +00:00
function(myx_message_send_error)
message(SEND_ERROR ${MyxColorBoldRed}${ARGV}${MyxColorReset})
endfunction()
2022-09-28 23:46:29 +00:00
function(myx_message_warning)
message(WARNING ${MyxColorRed}${ARGV}${MyxColorReset})
endfunction()
2022-10-01 13:42:36 +00:00
function(myx_message_deprecation)
message(DEPRECATION ${MyxColorBoldMagenta}${ARGV}${MyxColorReset})
endfunction()
2022-09-28 23:46:29 +00:00
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()