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

This commit is contained in:
Brad King 2002-12-11 11:49:08 -05:00
parent e9e3855c65
commit d6f98c2a82
7 changed files with 34 additions and 0 deletions

View File

@ -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)

View File

@ -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

View File

@ -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
/** /**

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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