diff options
author | Brad King <brad.king@kitware.com> | 2007-12-19 22:15:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-12-19 22:15:41 (GMT) |
commit | 73704ede42cdaa6e4a985329506d116db3425b3f (patch) | |
tree | 54ecbe01239632bda57e1cbf1377d9bfa9d48c55 /Source/cmSystemTools.cxx | |
parent | f0824c7a19b34a387ba159b0c80c2688ff6dae20 (diff) | |
download | CMake-73704ede42cdaa6e4a985329506d116db3425b3f.zip CMake-73704ede42cdaa6e4a985329506d116db3425b3f.tar.gz CMake-73704ede42cdaa6e4a985329506d116db3425b3f.tar.bz2 |
ENH: Enabled color printing of "Scanning dependencies of target ..." message.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 52e1ca2..6829bdc 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -23,6 +23,9 @@ #include <cmsys/RegularExpression.hxx> #include <cmsys/Directory.hxx> #include <cmsys/System.h> +#if defined(CMAKE_BUILD_WITH_CMAKE) +# include <cmsys/Terminal.h> +#endif #if defined(_WIN32) # include <windows.h> @@ -2087,3 +2090,36 @@ const char* cmSystemTools::GetExecutableDirectory() { return cmSystemToolsExecutableDirectory.c_str(); } + +//---------------------------------------------------------------------------- +#if defined(CMAKE_BUILD_WITH_CMAKE) +void cmSystemTools::MakefileColorEcho(int color, const char* message, + bool newline, bool enabled) +{ + // On some platforms (an MSYS prompt) cmsysTerminal may not be able + // to determine whether the stream is displayed on a tty. In this + // case it assumes no unless we tell it otherwise. Since we want + // color messages to be displayed for users we will assume yes. + // However, we can test for some situations when the answer is most + // likely no. + int assumeTTY = cmsysTerminal_Color_AssumeTTY; + if(cmSystemTools::GetEnv("DART_TEST_FROM_DART") || + cmSystemTools::GetEnv("DASHBOARD_TEST_FROM_CTEST") || + cmSystemTools::GetEnv("CTEST_INTERACTIVE_DEBUG_MODE")) + { + // Avoid printing color escapes during dashboard builds. + assumeTTY = 0; + } + + if(enabled) + { + cmsysTerminal_cfprintf(color | assumeTTY, stdout, "%s%s", + message, newline? "\n" : ""); + } + else + { + // Color is disabled. Print without color. + fprintf(stdout, "%s%s", message, newline? "\n" : ""); + } +} +#endif |