From 68b32ff801de1ecf4991ba04526e71b0f192b0d1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 24 Feb 2024 17:20:45 -0500 Subject: 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. --- Source/cmDebugTools.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/cmDebugTools.h b/Source/cmDebugTools.h index 99c0c6b..c3e05a6 100644 --- a/Source/cmDebugTools.h +++ b/Source/cmDebugTools.h @@ -4,6 +4,8 @@ #include +#include "cmSystemTools.h" + #define CM_DBG(expr) cm::dbg_impl(__FILE__, __LINE__, #expr, expr) namespace cm { @@ -13,8 +15,10 @@ namespace { template 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; } -- cgit v0.12