From 3bcbca96ab7424852e1cc4e15ef19174e40db224 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Dec 2002 14:15:35 -0500 Subject: ENH: Improved implementation of MSVC debug hook to only add the hook if DART_TEST_FROM_DART is set in the environment. This is better than always adding the hook and testing the environment from the callback. --- Source/cmCreateTestSourceList.cxx | 17 +++++++++-------- Source/cmSystemTools.cxx | 12 ++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index 62286bc..5ed0f44 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -96,7 +96,8 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& argsIn) "#include \n" "#include \n" "#include \n" - "#include \n"; + "#include \n" + "\n"; fout << "#if defined(_MSC_VER) && defined(_DEBUG)\n" "/* MSVC debug hook to prevent dialogs when running from DART. */\n" @@ -104,11 +105,8 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& argsIn) "static int TestDriverDebugReport(int type, char* message, int* retVal)\n" "{\n" " (void)type; (void)retVal;\n" - " if(getenv(\"DART_TEST_FROM_DART\"))\n" - " {\n" - " fprintf(stderr, message);\n" - " exit(1);\n" - " }\n" + " fprintf(stderr, message);\n" + " exit(1);\n" " return 0;\n" "}\n" "#endif\n"; @@ -221,8 +219,11 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& argsIn) " char *arg, *test_name;\n" " \n" "#if defined(_MSC_VER) && defined(_DEBUG)\n" - " /* Put in hook for debug library. */\n" - " _CrtSetReportHook(TestDriverDebugReport);\n" + " /* If running from DART, put in debug hook. */\n" + " if(getenv(\"DART_TEST_FROM_DART\"))\n" + " {\n" + " _CrtSetReportHook(TestDriverDebugReport);\n" + " }\n" "#endif\n" " \n" " NumTests = " << numTests << ";\n" diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7750349..ff27805 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2434,16 +2434,16 @@ void cmSystemTools::SplitProgramFromArgs(const char* path, # include static int cmSystemToolsDebugReport(int, char* message, int*) { - if(getenv("DART_TEST_FROM_DART")) - { - fprintf(stderr, message); - exit(1); - } + fprintf(stderr, message); + exit(1); return 0; } void cmSystemTools::EnableMSVCDebugHook() { - _CrtSetReportHook(cmSystemToolsDebugReport); + if(getenv("DART_TEST_FROM_DART")) + { + _CrtSetReportHook(cmSystemToolsDebugReport); + } } #else void cmSystemTools::EnableMSVCDebugHook() -- cgit v0.12