Explorar o código

ENH: Added cmSystemTools::EnableMSVCDebugHook() to prevent error dialogs when CMake is invoked by Dart.

Brad King %!s(int64=23) %!d(string=hai) anos
pai
achega
d6f98c2a82

+ 1 - 0
Source/cmDumpDocumentation.cxx

@@ -21,6 +21,7 @@
 
 
 int main(int ac, char** av)
 int main(int ac, char** av)
 {
 {
+  cmSystemTools::EnableMSVCDebugHook();
   cmake cmi;
   cmake cmi;
   const char* outname = "cmake.html";
   const char* outname = "cmake.html";
   if(ac > 1)
   if(ac > 1)

+ 23 - 0
Source/cmSystemTools.cxx

@@ -2427,3 +2427,26 @@ void cmSystemTools::SplitProgramFromArgs(const char* path,
   program = "";
   program = "";
   args = "";
   args = "";
 }
 }
+
+#if defined(_MSC_VER) && defined(_DEBUG)
+# include <crtdbg.h>
+# include <stdio.h>
+# include <stdlib.h>
+static int cmSystemToolsDebugReport(int, char* message, int*)
+{
+  if(getenv("DART_TEST_FROM_DART"))
+    {
+    fprintf(stderr, message);
+    exit(1);
+    }
+  return 0;
+}
+void cmSystemTools::EnableMSVCDebugHook()
+{
+  _CrtSetReportHook(cmSystemToolsDebugReport);
+}
+#else
+void cmSystemTools::EnableMSVCDebugHook()
+{
+}
+#endif

+ 6 - 0
Source/cmSystemTools.h

@@ -356,6 +356,12 @@ public:
    */
    */
   static void SetRunCommandHideConsole(bool v){s_RunCommandHideConsole = v;}
   static void SetRunCommandHideConsole(bool v){s_RunCommandHideConsole = v;}
   static bool GetRunCommandHideConsole(){ return s_RunCommandHideConsole;}
   static bool GetRunCommandHideConsole(){ return s_RunCommandHideConsole;}
+  
+  /** When building DEBUG with MSVC, this enables a hook that prevents
+   * error dialogs from popping up if the program is being run from
+   * DART.
+   */
+  static void EnableMSVCDebugHook();
 protected:
 protected:
   // these two functions can be called from ConvertToOutputPath
   // these two functions can be called from ConvertToOutputPath
   /**
   /**

+ 1 - 0
Source/cmakemain.cxx

@@ -25,6 +25,7 @@ void updateProgress(const char *msg, float prog, void *cd);
 
 
 int main(int ac, char** av)
 int main(int ac, char** av)
 {
 {
+  cmSystemTools::EnableMSVCDebugHook();
   int ret = do_cmake(ac, av);
   int ret = do_cmake(ac, av);
 #ifdef CMAKE_BUILD_WITH_CMAKE
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmDynamicLoader::FlushCache();
   cmDynamicLoader::FlushCache();

+ 1 - 0
Source/cmaketest.cxx

@@ -29,6 +29,7 @@ int do_cmaketest(int ac, char** av);
 
 
 int main(int ac, char** av)
 int main(int ac, char** av)
 {
 {
+  cmSystemTools::EnableMSVCDebugHook();
   int ret = do_cmaketest(ac, av);
   int ret = do_cmaketest(ac, av);
 #ifdef CMAKE_BUILD_WITH_CMAKE
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmDynamicLoader::FlushCache();
   cmDynamicLoader::FlushCache();

+ 1 - 0
Source/cmw9xcom.cxx

@@ -20,6 +20,7 @@
 // this is a test driver program for cmake.
 // this is a test driver program for cmake.
 int main (int argc, char *argv[])
 int main (int argc, char *argv[])
 {
 {
+  cmSystemTools::EnableMSVCDebugHook();
   if ( argc <= 1 )
   if ( argc <= 1 )
     {
     {
     std::cerr << "Usage: " << argv[0] << " executable" << std::endl;
     std::cerr << "Usage: " << argv[0] << " executable" << std::endl;

+ 1 - 0
Source/ctest.cxx

@@ -1422,6 +1422,7 @@ int ctest::ProcessTests()
 // this is a test driver program for cmake.
 // this is a test driver program for cmake.
 int main (int argc, char *argv[])
 int main (int argc, char *argv[])
 {
 {
+  cmSystemTools::EnableMSVCDebugHook();
   ctest inst;
   ctest inst;
   
   
   // look at the args
   // look at the args