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,4 +1,8 @@
if(NOT WIN32)
# [ -t 2 ] tests whether stderr is interactive.
# The negation '!' is because for POSIX shells, 0 is true and 1 is false.
execute_process(COMMAND [ ! -t 2 ] RESULT_VARIABLE IS_STDERR_INTERACTIVE)
if(IS_STDERR_INTERACTIVE)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(ColorBold "${Esc}[1m")
@ -16,4 +20,5 @@ if(NOT WIN32)
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif(IS_STDERR_INTERACTIVE)
endif()