Просмотр исходного кода

cmDebugTools: offer a way to disable `CM_DBG` output at runtime

This allows information to be gathered while debugging while also
supporting running the test suite with the debugging enabled to test
CMake module changes without tripping `stderr` output checkers.
Ben Boeckel 1 год назад
Родитель
Сommit
68b32ff801
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      Source/cmDebugTools.h

+ 6 - 2
Source/cmDebugTools.h

@@ -4,6 +4,8 @@
 
 #include <iostream>
 
+#include "cmSystemTools.h"
+
 #define CM_DBG(expr) cm::dbg_impl(__FILE__, __LINE__, #expr, expr)
 
 namespace cm {
@@ -13,8 +15,10 @@ namespace {
 template <typename T>
 T dbg_impl(const char* fname, int line, const char* expr, T value)
 {
-  std::cerr << fname << ':' << line << ": " << expr << " = " << value
-            << std::endl;
+  if (!cmSystemTools::GetEnvVar("CMAKE_NO_DBG")) {
+    std::cerr << fname << ':' << line << ": " << expr << " = " << value
+              << std::endl;
+  }
   return value;
 }