Description: Enable debug message with cmake

Reason: So it can be changed without touching the code
Files: CMakeLists.txt and Debug.h
This commit is contained in:
Martin Marmsoler 2023-02-15 19:30:34 +01:00
parent a5ab7c3e11
commit 310cbdf72e
2 changed files with 12 additions and 13 deletions

View File

@ -65,6 +65,9 @@ option(USE_SYSTEM_LUA "Use the system-wide Lua installation" OFF)
option(USE_SYSTEM_HUNSPELL "Use the system-wide hunspell installation" OFF)
option(USE_SYSTEM_CMARK "Use the system-wide cmark installation" OFF)
option(ENABLE_TESTS "Enable Gittyup Unittests" ON)
option(DEBUG_MESSAGES "Enable general debug messages" ON)
option(DEBUG_MESSAGES_REFRESH "Enable debug messages to debug the refresh flow"
ON)
set(LUA_MODULES_PATH
CACHE
@ -99,6 +102,13 @@ if(NOT DEBUG_OUTPUT)
add_compile_definitions(QT_NO_DEBUG_OUTPUT)
endif()
if(DEBUG_MESSAGES)
add_compile_definitions(DEBUG)
endif()
if(DEBUG_MESSAGES_REFRESH)
add_compile_definitions(DEBUG_REFRESH)
endif()
find_package(
Qt5 5.12
COMPONENTS ${QT_MODULES} LinguistTools

View File

@ -3,33 +3,22 @@
#include <QDebug>
#define DEBUG 1
#define DEBUG_REFRESH 1
#if DEBUG == 0
#ifdef DEBUG
#define Debug(x) \
do { \
qDebug() << x; \
} while (false)
#else
#define Debug(x)
#endif
#if DEBUG_REFRESH == 1
#ifdef DEBUG_REFRESH
#define DebugRefresh(x) \
do { \
qDebug() << Q_FUNC_INFO << QStringLiteral(": ") << x; \
} while (false)
#else
#define DebugRefresh(x)
#endif
#endif // DEBUG_H