diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2004-01-07 16:24:22 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2004-01-07 16:24:22 (GMT) |
commit | 2c2291bbe03aec2dd6637a5311204f09ff6c58ba (patch) | |
tree | 35947ba07840f9ea939e33567c1e6c3e79a37132 /Source/cmSystemTools.cxx | |
parent | a8620773f3b934752062015a0df9fbe100e10dc7 (diff) | |
download | CMake-2c2291bbe03aec2dd6637a5311204f09ff6c58ba.zip CMake-2c2291bbe03aec2dd6637a5311204f09ff6c58ba.tar.gz CMake-2c2291bbe03aec2dd6637a5311204f09ff6c58ba.tar.bz2 |
ENH: add new feature to ctest so that it can cmake, build and run a test executable
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 06ba069..87a33a0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -64,7 +64,9 @@ const char* cmSystemTools::GetWindows9xComspecSubstitute() } void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&, void*); +void (*cmSystemTools::s_StdoutCallback)(const char*, int len, void*); void* cmSystemTools::s_ErrorCallbackClientData = 0; +void* cmSystemTools::s_StdoutCallbackClientData = 0; // replace replace with with as many times as it shows up in source. // write the result into source. @@ -221,6 +223,37 @@ void cmSystemTools::SetErrorCallback(ErrorCallback f, void* clientData) s_ErrorCallbackClientData = clientData; } +void cmSystemTools::SetStdoutCallback(StdoutCallback f, void* clientData) +{ + s_StdoutCallback = f; + s_StdoutCallbackClientData = clientData; +} + +void cmSystemTools::Stdout(const char* s) +{ + if(s_StdoutCallback) + { + (*s_StdoutCallback)(s, strlen(s), s_StdoutCallbackClientData); + } + else + { + std::cout << s; + std::cout << std::flush; + } +} + +void cmSystemTools::Stdout(const char* s, int length) +{ + if(s_StdoutCallback) + { + (*s_StdoutCallback)(s, length, s_StdoutCallbackClientData); + } + else + { + std::cout.write(s, length); + } +} + void cmSystemTools::Message(const char* m1, const char *title) { if(s_DisableMessages) @@ -411,7 +444,7 @@ bool cmSystemTools::RunSingleCommand( } if(verbose) { - std::cout.write(data, length); + cmSystemTools::Stdout(data, length); } } @@ -590,7 +623,9 @@ bool RunCommandViaPopen(const char* command, char buffer[BUFFER_SIZE]; if(verbose) { - std::cout << "running " << command << std::endl; + cmSystemTools::Stdout("running "); + cmSystemTools::Stdout(command); + cmSystemTools::Stdout("\n"); } fflush(stdout); fflush(stderr); @@ -604,7 +639,7 @@ bool RunCommandViaPopen(const char* command, { if(verbose) { - std::cout << buffer << std::flush; + cmSystemTools::Stdout(buffer); } output += buffer; fgets(buffer, BUFFER_SIZE, cpipe); |