Browse Source

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.
Brad King 11 years ago
parent
commit
92ddf0c9e2
2 changed files with 18 additions and 0 deletions
  1. 16 0
      Source/QtDialog/QCMake.cxx
  2. 2 0
      Source/QtDialog/QCMake.h

+ 16 - 0
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;

+ 2 - 0
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;