[Cmake-commits] CMake branch, next, updated. v3.0.0-rc5-3157-g68983d2
Brad King
brad.king at kitware.com
Thu May 15 11:10:47 EDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 68983d2833be28caecd8d34867c88a8afc8631d3 (commit)
via 209cd475ebf492616ec21cf55c7557e090c2a18f (commit)
via d7c692466bf100b077ffd0eef3a51fe1316782f0 (commit)
via 92ddf0c9e20af6158d84db34eeba795061fad1e9 (commit)
via f52b5ae3c4a87723f90f63249a979424aaf99407 (commit)
via a9ae1d7a605333f0dea6d709e27a177b19f8c2ae (commit)
via 73b13f56413cac74d90a2ab1938add3bbe740ecb (commit)
via 7577a542dfa0aac045b97bfe4440241583c62e3a (commit)
via b1b4d761a1991ce3634195b0b5be251ec43295c4 (commit)
from 5ca7b3792b74f2fbaa6369dd34acfe4a6c2d8d04 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=68983d2833be28caecd8d34867c88a8afc8631d3
commit 68983d2833be28caecd8d34867c88a8afc8631d3
Merge: 5ca7b37 209cd47
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 11:10:46 2014 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu May 15 11:10:46 2014 -0400
Merge topic 'cmake-gui-capture-output' into next
209cd475 Help: Add notes for topic 'cmake-gui-capture-output'
d7c69246 execute_process: Send stderr through cmSystemTools::Stderr
92ddf0c9 cmake-gui: Capture cmSystemTools::Stdout and Stderr
f52b5ae3 cmSystemTools: Add callback for Stderr
a9ae1d7a cmSystemTools: Simplify InterruptCallback definition
73b13f56 cmSystemTools: Rename ErrorCallback to MessageCallback
7577a542 cmCTestBuildAndTestHandler: Refactor output capture
b1b4d761 cmCTestBuildAndTestHandler: Refactor local loop var
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=209cd475ebf492616ec21cf55c7557e090c2a18f
commit 209cd475ebf492616ec21cf55c7557e090c2a18f
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 11:10:52 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 11:10:52 2014 -0400
Help: Add notes for topic 'cmake-gui-capture-output'
diff --git a/Help/release/dev/cmake-gui-capture-output.rst b/Help/release/dev/cmake-gui-capture-output.rst
new file mode 100644
index 0000000..40cd25e
--- /dev/null
+++ b/Help/release/dev/cmake-gui-capture-output.rst
@@ -0,0 +1,6 @@
+cmake-gui-capture-output
+------------------------
+
+* The :manual:`cmake-gui(1)` learned to capture output from child
+ processes started by the :command:`execute_process` command
+ and display it in the output window.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d7c692466bf100b077ffd0eef3a51fe1316782f0
commit d7c692466bf100b077ffd0eef3a51fe1316782f0
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 09:48:39 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 10:29:08 2014 -0400
execute_process: Send stderr through cmSystemTools::Stderr
Give cmake-gui and ctest --build-and-test a chance to capture the output
instead of sending it to the real stderr.
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 40f70b8..11f8ae5 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -256,10 +256,6 @@ bool cmExecuteProcessCommand
// Check the output variables.
bool merge_output = (output_variable == error_variable);
- if(error_variable.empty() && !error_quiet)
- {
- cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
- }
if(!input_file.empty())
{
cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN, input_file.c_str());
@@ -307,7 +303,11 @@ bool cmExecuteProcessCommand
}
else if(p == cmsysProcess_Pipe_STDERR && !error_quiet)
{
- if(!error_variable.empty())
+ if(error_variable.empty())
+ {
+ cmSystemTools::Stderr(data, length);
+ }
+ else
{
cmExecuteProcessCommandAppend(tempError, data, length);
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92ddf0c9e20af6158d84db34eeba795061fad1e9
commit 92ddf0c9e20af6158d84db34eeba795061fad1e9
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 09:47:25 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 10:28:42 2014 -0400
cmake-gui: Capture cmSystemTools::Stdout and Stderr
Output sent through these APIs is logically part of the CMake process
output. Capture it with callbacks and display it in the cmake-gui
output window along with other messages.
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index f2a23bb..b833648 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -36,6 +36,8 @@ QCMake::QCMake(QObject* p)
cmSystemTools::DisableRunCommandOutput();
cmSystemTools::SetRunCommandHideConsole(true);
cmSystemTools::SetMessageCallback(QCMake::messageCallback, this);
+ cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this);
+ cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this);
this->CMakeInstance = new cmake;
this->CMakeInstance->SetCMakeEditCommand(
@@ -356,6 +358,20 @@ void QCMake::messageCallback(const char* msg, const char* /*title*/,
QCoreApplication::processEvents();
}
+void QCMake::stdoutCallback(const char* msg, size_t len, void* cd)
+{
+ QCMake* self = reinterpret_cast<QCMake*>(cd);
+ emit self->outputMessage(QString::fromLocal8Bit(msg,int(len)));
+ QCoreApplication::processEvents();
+}
+
+void QCMake::stderrCallback(const char* msg, size_t len, void* cd)
+{
+ QCMake* self = reinterpret_cast<QCMake*>(cd);
+ emit self->outputMessage(QString::fromLocal8Bit(msg,int(len)));
+ QCoreApplication::processEvents();
+}
+
QString QCMake::binaryDirectory() const
{
return this->BinaryDirectory;
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 8e71ea5..bd82f0d 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -138,6 +138,8 @@ protected:
static void progressCallback(const char* msg, float percent, void* cd);
static void messageCallback(const char* msg, const char* title,
bool&, void* cd);
+ static void stdoutCallback(const char* msg, size_t len, void* cd);
+ static void stderrCallback(const char* msg, size_t len, void* cd);
bool SuppressDevWarnings;
bool WarnUninitializedMode;
bool WarnUnusedMode;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f52b5ae3c4a87723f90f63249a979424aaf99407
commit f52b5ae3c4a87723f90f63249a979424aaf99407
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 09:44:25 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 10:26:30 2014 -0400
cmSystemTools: Add callback for Stderr
Factor a common callback type out of StdoutCallback. Add an equivalent
StderrCallback. While at it, use "size_t" for the data length instead
of "int".
Teach "ctest --build-and-test" to capture the Stderr callback because
output sent through it is part of the logical CMake process output.
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 6756dbf..b4818be 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -156,7 +156,7 @@ void CMakeProgressCallback(const char*msg, float , void * s)
}
//----------------------------------------------------------------------
-void CMakeStdoutCallback(const char* m, int len, void* s)
+void CMakeOutputCallback(const char* m, size_t len, void* s)
{
std::string* out = (std::string*)s;
out->append(m, len);
@@ -170,12 +170,14 @@ public:
cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s): CM(cm)
{
cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s);
- cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &s);
+ cmSystemTools::SetStdoutCallback(CMakeOutputCallback, &s);
+ cmSystemTools::SetStderrCallback(CMakeOutputCallback, &s);
this->CM.SetProgressCallback(CMakeProgressCallback, &s);
}
~cmCTestBuildAndTestCaptureRAII()
{
this->CM.SetProgressCallback(0, 0);
+ cmSystemTools::SetStderrCallback(0, 0);
cmSystemTools::SetStdoutCallback(0, 0);
cmSystemTools::SetMessageCallback(0, 0);
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 0289430..2e417cb 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -122,10 +122,12 @@ bool cmSystemTools::s_DisableMessages = false;
bool cmSystemTools::s_ForceUnixPaths = false;
cmSystemTools::MessageCallback cmSystemTools::s_MessageCallback;
+cmSystemTools::OutputCallback cmSystemTools::s_StdoutCallback;
+cmSystemTools::OutputCallback cmSystemTools::s_StderrCallback;
cmSystemTools::InterruptCallback cmSystemTools::s_InterruptCallback;
-void (*cmSystemTools::s_StdoutCallback)(const char*, int len, void*);
void* cmSystemTools::s_MessageCallbackClientData;
-void* cmSystemTools::s_StdoutCallbackClientData = 0;
+void* cmSystemTools::s_StdoutCallbackClientData;
+void* cmSystemTools::s_StderrCallbackClientData;
void* cmSystemTools::s_InterruptCallbackClientData;
// replace replace with with as many times as it shows up in source.
@@ -259,33 +261,42 @@ void cmSystemTools::SetMessageCallback(MessageCallback f, void* clientData)
s_MessageCallbackClientData = clientData;
}
-void cmSystemTools::SetStdoutCallback(StdoutCallback f, void* clientData)
+void cmSystemTools::SetStdoutCallback(OutputCallback f, void* clientData)
{
s_StdoutCallback = f;
s_StdoutCallbackClientData = clientData;
}
+void cmSystemTools::SetStderrCallback(OutputCallback f, void* clientData)
+{
+ s_StderrCallback = f;
+ s_StderrCallbackClientData = clientData;
+}
+
void cmSystemTools::Stdout(const char* s)
{
- if(s_StdoutCallback)
+ cmSystemTools::Stdout(s, strlen(s));
+}
+
+void cmSystemTools::Stderr(const char* s)
+{
+ cmSystemTools::Stderr(s, strlen(s));
+}
+
+void cmSystemTools::Stderr(const char* s, size_t length)
+{
+ if(s_StderrCallback)
{
- (*s_StdoutCallback)(s, static_cast<int>(strlen(s)),
- s_StdoutCallbackClientData);
+ (*s_StderrCallback)(s, length, s_StderrCallbackClientData);
}
else
{
- std::cout << s;
- std::cout.flush();
- }
-}
-
-void cmSystemTools::Stderr(const char* s, int length)
-{
std::cerr.write(s, length);
std::cerr.flush();
+ }
}
-void cmSystemTools::Stdout(const char* s, int length)
+void cmSystemTools::Stdout(const char* s, size_t length)
{
if(s_StdoutCallback)
{
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 979551c..4455dd1 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -77,14 +77,17 @@ public:
*/
static void Message(const char* m, const char* title=0);
+ typedef void (*OutputCallback)(const char*, size_t length, void*);
+
///! Send a string to stdout
static void Stdout(const char* s);
- static void Stdout(const char* s, int length);
- typedef void (*StdoutCallback)(const char*, int length, void*);
- static void SetStdoutCallback(StdoutCallback, void* clientData=0);
+ static void Stdout(const char* s, size_t length);
+ static void SetStdoutCallback(OutputCallback, void* clientData=0);
- ///! Send a string to stderr. Stdout callbacks will not be invoced.
- static void Stderr(const char* s, int length);
+ ///! Send a string to stderr
+ static void Stderr(const char* s);
+ static void Stderr(const char* s, size_t length);
+ static void SetStderrCallback(OutputCallback, void* clientData=0);
typedef bool (*InterruptCallback)(void*);
@@ -471,10 +474,12 @@ private:
static bool s_DisableMessages;
static bool s_DisableRunCommandOutput;
static MessageCallback s_MessageCallback;
- static StdoutCallback s_StdoutCallback;
+ static OutputCallback s_StdoutCallback;
+ static OutputCallback s_StderrCallback;
static InterruptCallback s_InterruptCallback;
static void* s_MessageCallbackClientData;
static void* s_StdoutCallbackClientData;
+ static void* s_StderrCallbackClientData;
static void* s_InterruptCallbackClientData;
};
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a9ae1d7a605333f0dea6d709e27a177b19f8c2ae
commit a9ae1d7a605333f0dea6d709e27a177b19f8c2ae
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 09:40:03 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 10:24:23 2014 -0400
cmSystemTools: Simplify InterruptCallback definition
Use the typedef to declare the member instead of duplicating the type.
Use default initialization instead of an explicit zero initializer.
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index f61d75d..0289430 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -122,11 +122,11 @@ bool cmSystemTools::s_DisableMessages = false;
bool cmSystemTools::s_ForceUnixPaths = false;
cmSystemTools::MessageCallback cmSystemTools::s_MessageCallback;
+cmSystemTools::InterruptCallback cmSystemTools::s_InterruptCallback;
void (*cmSystemTools::s_StdoutCallback)(const char*, int len, void*);
void* cmSystemTools::s_MessageCallbackClientData;
void* cmSystemTools::s_StdoutCallbackClientData = 0;
-bool (*cmSystemTools::s_InterruptCallback)(void*);
-void* cmSystemTools::s_InterruptCallbackClientData = 0;
+void* cmSystemTools::s_InterruptCallbackClientData;
// replace replace with with as many times as it shows up in source.
// write the result into source.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73b13f56413cac74d90a2ab1938add3bbe740ecb
commit 73b13f56413cac74d90a2ab1938add3bbe740ecb
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 09:38:30 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 10:24:21 2014 -0400
cmSystemTools: Rename ErrorCallback to MessageCallback
Clarify that it is the callback for the cmSystemTools::Message API.
Rename callback clients too.
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 9a6b40e..6756dbf 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -169,7 +169,7 @@ class cmCTestBuildAndTestCaptureRAII
public:
cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s): CM(cm)
{
- cmSystemTools::SetErrorCallback(CMakeMessageCallback, &s);
+ cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s);
cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &s);
this->CM.SetProgressCallback(CMakeProgressCallback, &s);
}
@@ -177,7 +177,7 @@ public:
{
this->CM.SetProgressCallback(0, 0);
cmSystemTools::SetStdoutCallback(0, 0);
- cmSystemTools::SetErrorCallback(0, 0);
+ cmSystemTools::SetMessageCallback(0, 0);
}
};
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 2d1ef5c..d70bedb 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -73,7 +73,8 @@ void onsig(int)
}
-void CMakeErrorHandler(const char* message, const char* title, bool&, void* clientData)
+void CMakeMessageHandler(const char* message, const char* title, bool&,
+ void* clientData)
{
cmCursesForm* self = static_cast<cmCursesForm*>( clientData );
self->AddError(message, title);
@@ -171,7 +172,7 @@ int main(int argc, char const* const* argv)
return 1;
}
- cmSystemTools::SetErrorCallback(CMakeErrorHandler, myform);
+ cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
cmCursesForm::CurrentForm = myform;
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 5f9ebaf..f2a23bb 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -35,7 +35,7 @@ QCMake::QCMake(QObject* p)
cmSystemTools::DisableRunCommandOutput();
cmSystemTools::SetRunCommandHideConsole(true);
- cmSystemTools::SetErrorCallback(QCMake::errorCallback, this);
+ cmSystemTools::SetMessageCallback(QCMake::messageCallback, this);
this->CMakeInstance = new cmake;
this->CMakeInstance->SetCMakeEditCommand(
@@ -348,8 +348,8 @@ void QCMake::progressCallback(const char* msg, float percent, void* cd)
QCoreApplication::processEvents();
}
-void QCMake::errorCallback(const char* msg, const char* /*title*/,
- bool& /*stop*/, void* cd)
+void QCMake::messageCallback(const char* msg, const char* /*title*/,
+ bool& /*stop*/, void* cd)
{
QCMake* self = reinterpret_cast<QCMake*>(cd);
emit self->errorMessage(QString::fromLocal8Bit(msg));
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 93ac8ab..8e71ea5 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -136,8 +136,8 @@ protected:
static bool interruptCallback(void*);
static void progressCallback(const char* msg, float percent, void* cd);
- static void errorCallback(const char* msg, const char* title,
- bool&, void* cd);
+ static void messageCallback(const char* msg, const char* title,
+ bool&, void* cd);
bool SuppressDevWarnings;
bool WarnUninitializedMode;
bool WarnUnusedMode;
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index c38a99c..f61d75d 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -121,10 +121,9 @@ bool cmSystemTools::s_FatalErrorOccured = false;
bool cmSystemTools::s_DisableMessages = false;
bool cmSystemTools::s_ForceUnixPaths = false;
-void (*cmSystemTools::s_ErrorCallback)(const char*, const char*,
- bool&, void*);
+cmSystemTools::MessageCallback cmSystemTools::s_MessageCallback;
void (*cmSystemTools::s_StdoutCallback)(const char*, int len, void*);
-void* cmSystemTools::s_ErrorCallbackClientData = 0;
+void* cmSystemTools::s_MessageCallbackClientData;
void* cmSystemTools::s_StdoutCallbackClientData = 0;
bool (*cmSystemTools::s_InterruptCallback)(void*);
void* cmSystemTools::s_InterruptCallbackClientData = 0;
@@ -254,10 +253,10 @@ bool cmSystemTools::GetInterruptFlag()
return false;
}
-void cmSystemTools::SetErrorCallback(ErrorCallback f, void* clientData)
+void cmSystemTools::SetMessageCallback(MessageCallback f, void* clientData)
{
- s_ErrorCallback = f;
- s_ErrorCallbackClientData = clientData;
+ s_MessageCallback = f;
+ s_MessageCallbackClientData = clientData;
}
void cmSystemTools::SetStdoutCallback(StdoutCallback f, void* clientData)
@@ -305,10 +304,10 @@ void cmSystemTools::Message(const char* m1, const char *title)
{
return;
}
- if(s_ErrorCallback)
+ if(s_MessageCallback)
{
- (*s_ErrorCallback)(m1, title, s_DisableMessages,
- s_ErrorCallbackClientData);
+ (*s_MessageCallback)(m1, title, s_DisableMessages,
+ s_MessageCallbackClientData);
return;
}
else
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 27b4bce..979551c 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -57,14 +57,14 @@ public:
*/
static std::string TrimWhitespace(const std::string& s);
- typedef void (*ErrorCallback)(const char*, const char*, bool&, void*);
+ typedef void (*MessageCallback)(const char*, const char*, bool&, void*);
/**
* Set the function used by GUIs to display error messages
* Function gets passed: message as a const char*,
* title as a const char*, and a reference to bool that when
* set to false, will disable furthur messages (cancel).
*/
- static void SetErrorCallback(ErrorCallback f, void* clientData=0);
+ static void SetMessageCallback(MessageCallback f, void* clientData=0);
/**
* Display an error message.
@@ -470,10 +470,10 @@ private:
static bool s_FatalErrorOccured;
static bool s_DisableMessages;
static bool s_DisableRunCommandOutput;
- static ErrorCallback s_ErrorCallback;
+ static MessageCallback s_MessageCallback;
static StdoutCallback s_StdoutCallback;
static InterruptCallback s_InterruptCallback;
- static void* s_ErrorCallbackClientData;
+ static void* s_MessageCallbackClientData;
static void* s_StdoutCallbackClientData;
static void* s_InterruptCallbackClientData;
};
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index fcaa127..77f1e4e 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -129,8 +129,8 @@ static std::string cmakemainGetStack(void *clientdata)
return msg;
}
-static void cmakemainErrorCallback(const char* m, const char*, bool&,
- void *clientdata)
+static void cmakemainMessageCallback(const char* m, const char*, bool&,
+ void *clientdata)
{
std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
}
@@ -310,7 +310,7 @@ int do_cmake(int ac, char const* const* av)
return ret;
}
cmake cm;
- cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm);
+ cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm);
cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
cm.SetWorkingMode(workingMode);
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7577a542dfa0aac045b97bfe4440241583c62e3a
commit 7577a542dfa0aac045b97bfe4440241583c62e3a
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 10:19:29 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 10:19:29 2014 -0400
cmCTestBuildAndTestHandler: Refactor output capture
Use an RAII class to add and remove callbacks.
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index ac2196c..9a6b40e 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -161,28 +161,29 @@ void CMakeStdoutCallback(const char* m, int len, void* s)
std::string* out = (std::string*)s;
out->append(m, len);
}
-struct cmSetupOutputCaptureCleanup
+
+//----------------------------------------------------------------------
+class cmCTestBuildAndTestCaptureRAII
{
- ~cmSetupOutputCaptureCleanup()
- {
- cmSystemTools::SetErrorCallback(0, 0);
+ cmake& CM;
+public:
+ cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s): CM(cm)
+ {
+ cmSystemTools::SetErrorCallback(CMakeMessageCallback, &s);
+ cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &s);
+ this->CM.SetProgressCallback(CMakeProgressCallback, &s);
+ }
+ ~cmCTestBuildAndTestCaptureRAII()
+ {
+ this->CM.SetProgressCallback(0, 0);
cmSystemTools::SetStdoutCallback(0, 0);
- }
+ cmSystemTools::SetErrorCallback(0, 0);
+ }
};
//----------------------------------------------------------------------
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{
- std::string cmakeOutString;
- cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString);
- cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString);
- // make sure SetStdoutCallback and SetErrorCallback are set to null
- // after this function exits so that they do not point at a destroyed
- // string cmakeOutString
- cmSetupOutputCaptureCleanup cleanup;
- static_cast<void>(cleanup);
- cmOStringStream out;
-
// if the generator and make program are not specified then it is an error
if (!this->BuildGenerator.size())
{
@@ -196,6 +197,12 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
return 1;
}
+ cmake cm;
+ std::string cmakeOutString;
+ cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
+ static_cast<void>(captureRAII);
+ cmOStringStream out;
+
if ( this->CTest->GetConfigType().size() == 0 &&
this->ConfigSample.size())
{
@@ -232,10 +239,6 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
cmSystemTools::ChangeDirectory(this->BinaryDir.c_str());
- // should we cmake?
- cmake cm;
- cm.SetProgressCallback(CMakeProgressCallback, &cmakeOutString);
-
if(this->BuildNoCMake)
{
// Make the generator available for the Build call below.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b1b4d761a1991ce3634195b0b5be251ec43295c4
commit b1b4d761a1991ce3634195b0b5be251ec43295c4
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 10:16:48 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 10:16:48 2014 -0400
cmCTestBuildAndTestHandler: Refactor local loop var
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 4a3eec5..ac2196c 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -173,7 +173,6 @@ struct cmSetupOutputCaptureCleanup
//----------------------------------------------------------------------
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{
- unsigned int k;
std::string cmakeOutString;
cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString);
cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString);
@@ -369,7 +368,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::vector<const char*> testCommand;
testCommand.push_back(fullPath.c_str());
- for(k=0; k < this->TestCommandArgs.size(); ++k)
+ for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
{
testCommand.push_back(this->TestCommandArgs[k].c_str());
}
@@ -383,7 +382,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmSystemTools::ChangeDirectory(this->BuildRunDir.c_str());
}
out << "Running test command: \"" << fullPath << "\"";
- for(k=0; k < this->TestCommandArgs.size(); ++k)
+ for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
{
out << " \"" << this->TestCommandArgs[k] << "\"";
}
-----------------------------------------------------------------------
Summary of changes:
Help/release/dev/cmake-gui-capture-output.rst | 6 +++
Source/CTest/cmCTestBuildAndTestHandler.cxx | 50 +++++++++++----------
Source/CursesDialog/ccmake.cxx | 5 ++-
Source/QtDialog/QCMake.cxx | 22 +++++++--
Source/QtDialog/QCMake.h | 6 ++-
Source/cmExecuteProcessCommand.cxx | 10 ++---
Source/cmSystemTools.cxx | 60 ++++++++++++++-----------
Source/cmSystemTools.h | 25 ++++++-----
Source/cmakemain.cxx | 6 +--
9 files changed, 117 insertions(+), 73 deletions(-)
create mode 100644 Help/release/dev/cmake-gui-capture-output.rst
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list