summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2004-01-07 16:24:22 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2004-01-07 16:24:22 (GMT)
commit2c2291bbe03aec2dd6637a5311204f09ff6c58ba (patch)
tree35947ba07840f9ea939e33567c1e6c3e79a37132 /Source/cmSystemTools.cxx
parenta8620773f3b934752062015a0df9fbe100e10dc7 (diff)
downloadCMake-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.cxx41
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);