diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2024-02-24 22:20:45 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2024-02-24 22:22:13 (GMT) |
commit | 68b32ff801de1ecf4991ba04526e71b0f192b0d1 (patch) | |
tree | 77bfc5f6876393ec9dfd7efef550b1012bc6dc35 /Source/cmDebugTools.h | |
parent | 709f4ea1de85ca2112ea2abedfc7d50f9f3fa3e2 (diff) | |
download | CMake-68b32ff801de1ecf4991ba04526e71b0f192b0d1.zip CMake-68b32ff801de1ecf4991ba04526e71b0f192b0d1.tar.gz CMake-68b32ff801de1ecf4991ba04526e71b0f192b0d1.tar.bz2 |
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.
Diffstat (limited to 'Source/cmDebugTools.h')
-rw-r--r-- | Source/cmDebugTools.h | 8 |
1 files 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 <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; } |