Merge pull request #137 from kkofler/fix-issue-124

CMakeColors.cmake: Use colors only if stderr is an interactive terminal.
This commit is contained in:
Manjaro Linux 2014-11-06 09:16:21 +01:00
commit 76421e300d

View File

@ -1,19 +1,24 @@
if(NOT WIN32) if(NOT WIN32)
string(ASCII 27 Esc) # [ -t 2 ] tests whether stderr is interactive.
set(ColorReset "${Esc}[m") # The negation '!' is because for POSIX shells, 0 is true and 1 is false.
set(ColorBold "${Esc}[1m") execute_process(COMMAND [ ! -t 2 ] RESULT_VARIABLE IS_STDERR_INTERACTIVE)
set(Red "${Esc}[31m") if(IS_STDERR_INTERACTIVE)
set(Green "${Esc}[32m") string(ASCII 27 Esc)
set(Yellow "${Esc}[33m") set(ColorReset "${Esc}[m")
set(Blue "${Esc}[34m") set(ColorBold "${Esc}[1m")
set(Magenta "${Esc}[35m") set(Red "${Esc}[31m")
set(Cyan "${Esc}[36m") set(Green "${Esc}[32m")
set(White "${Esc}[37m") set(Yellow "${Esc}[33m")
set(BoldRed "${Esc}[1;31m") set(Blue "${Esc}[34m")
set(BoldGreen "${Esc}[1;32m") set(Magenta "${Esc}[35m")
set(BoldYellow "${Esc}[1;33m") set(Cyan "${Esc}[36m")
set(BoldBlue "${Esc}[1;34m") set(White "${Esc}[37m")
set(BoldMagenta "${Esc}[1;35m") set(BoldRed "${Esc}[1;31m")
set(BoldCyan "${Esc}[1;36m") set(BoldGreen "${Esc}[1;32m")
set(BoldWhite "${Esc}[1;37m") set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif(IS_STDERR_INTERACTIVE)
endif() endif()