mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-04 07:55:34 +00:00
Add CMake argument ENABLE_VERBOSE_LOGGING, disable trace/debug logging in Release builds
This commit is contained in:
@ -115,13 +115,14 @@ Note that `ENABLE_GLES` will be forcibly set to `ON` for Emscripten and Android
|
|||||||
The following table contains a list of build options which are only useful in special circumstances, e.g. when
|
The following table contains a list of build options which are only useful in special circumstances, e.g. when
|
||||||
developing libprojectM, trying experimental features or building the library for a special use-case/environment.
|
developing libprojectM, trying experimental features or building the library for a special use-case/environment.
|
||||||
|
|
||||||
| CMake option | Default | Required dependencies | Description |
|
| CMake option | Default | Required dependencies | Description |
|
||||||
|------------------------|---------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|--------------------------|---------|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `ENABLE_SDL_UI` | `ON` | `SDL2` | Builds the SDL-based test application. Only used for development testing, will not be installed. |
|
| `ENABLE_SDL_UI` | `ON` | `SDL2` | Builds the SDL-based test application. Only used for development testing, will not be installed. |
|
||||||
| `ENABLE_INSTALL` | `OFF` | Building as a CMake subproject | Enable projectM install targets when built as a subproject via `add_subdirectory()`. |
|
| `ENABLE_INSTALL` | `OFF` | Building as a CMake subproject | Enable projectM install targets when built as a subproject via `add_subdirectory()`. |
|
||||||
| `ENABLE_DEBUG_POSTFIX` | `ON` | | Adds `d` (by default) to the name of any binary file in debug builds. |
|
| `ENABLE_DEBUG_POSTFIX` | `ON` | | Adds `d` (by default) to the name of any binary file in debug builds. |
|
||||||
| `ENABLE_SYSTEM_GLM` | `OFF` | | Builds against a system-installed GLM library. |
|
| `ENABLE_SYSTEM_GLM` | `OFF` | | Builds against a system-installed GLM library. |
|
||||||
| `ENABLE_CXX_INTERFACE` | `OFF` | | Exports symbols for the `ProjectM` and `PCM` C++ classes and installs the additional the headers. Using the C++ interface is not recommended and unsupported. |
|
| `ENABLE_CXX_INTERFACE` | `OFF` | | Exports symbols for the `ProjectM` and `PCM` C++ classes and installs the additional the headers. Using the C++ interface is not recommended and unsupported. |
|
||||||
|
| `ENABLE_VERBOSE_LOGGING` | `OFF` | | Enables code for `TRACE` and `DEBUG` log levels in release builds. By default, these will only be compiled for `Debug` builds. Enabling this will negatively affect performance, even if the actual log level is set to `INFORMATION` or higher. |
|
||||||
|
|
||||||
### Path options
|
### Path options
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ option(ENABLE_DEBUG_POSTFIX "Add \"d\" (by default) after library names for debu
|
|||||||
option(ENABLE_PLAYLIST "Enable building the playlist management library" ON)
|
option(ENABLE_PLAYLIST "Enable building the playlist management library" ON)
|
||||||
option(ENABLE_BOOST_FILESYSTEM "Force the use of boost::filesystem, even if the compiler supports C++17." OFF)
|
option(ENABLE_BOOST_FILESYSTEM "Force the use of boost::filesystem, even if the compiler supports C++17." OFF)
|
||||||
option(ENABLE_SDL_UI "Build the SDL2-based developer test UI. Ignored when building with Emscripten or for Android." OFF)
|
option(ENABLE_SDL_UI "Build the SDL2-based developer test UI. Ignored when building with Emscripten or for Android." OFF)
|
||||||
|
option(ENABLE_VERBOSE_LOGGING "Enables TRACE and DEBUG logging even in release builds, negatively affecting the performance." OFF)
|
||||||
|
|
||||||
option(BUILD_TESTING "Build the libprojectM test suite" OFF)
|
option(BUILD_TESTING "Build the libprojectM test suite" OFF)
|
||||||
option(BUILD_DOCS "Build documentation" OFF)
|
option(BUILD_DOCS "Build documentation" OFF)
|
||||||
@ -208,6 +209,11 @@ else()
|
|||||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Disable trace/debug logging in release builds unless explicitly requested
|
||||||
|
add_compile_definitions(
|
||||||
|
$<$<OR:$<CONFIG:Debug>,$<BOOL:${ENABLE_VERBOSE_LOGGING}>>:ENABLE_DEBUG_LOGGING>
|
||||||
|
)
|
||||||
|
|
||||||
if(BUILD_DOCS)
|
if(BUILD_DOCS)
|
||||||
find_package(Doxygen REQUIRED)
|
find_package(Doxygen REQUIRED)
|
||||||
find_package(Sphinx REQUIRED breathe exhale)
|
find_package(Sphinx REQUIRED breathe exhale)
|
||||||
@ -220,15 +226,15 @@ if(BUILD_DOCS)
|
|||||||
set(DOXYGEN_EXCLUDE_PATTERNS "*.cpp")
|
set(DOXYGEN_EXCLUDE_PATTERNS "*.cpp")
|
||||||
|
|
||||||
doxygen_add_docs(
|
doxygen_add_docs(
|
||||||
projectm_doxygen
|
projectm_doxygen
|
||||||
src
|
src
|
||||||
COMMENT "Generate HTML documentation")
|
COMMENT "Generate HTML documentation")
|
||||||
|
|
||||||
sphinx_add_docs(
|
sphinx_add_docs(
|
||||||
projectm_sphinx
|
projectm_sphinx
|
||||||
BREATHE_PROJECTS projectm_doxygen
|
BREATHE_PROJECTS projectm_doxygen
|
||||||
BUILDER html
|
BUILDER html
|
||||||
SOURCE_DIRECTORY docs)
|
SOURCE_DIRECTORY docs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(vendor)
|
add_subdirectory(vendor)
|
||||||
|
|||||||
@ -109,6 +109,7 @@ private:
|
|||||||
thread_local static LogLevel m_threadLogLevel; //!< The thread-specific log level.
|
thread_local static LogLevel m_threadLogLevel; //!< The thread-specific log level.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef ENABLE_DEBUG_LOGGING
|
||||||
#define LOG_TRACE(message) \
|
#define LOG_TRACE(message) \
|
||||||
if (Logging::HasCallback() && Logging::GetLogLevel() == Logging::LogLevel::Trace) \
|
if (Logging::HasCallback() && Logging::GetLogLevel() == Logging::LogLevel::Trace) \
|
||||||
{ \
|
{ \
|
||||||
@ -120,6 +121,10 @@ private:
|
|||||||
{ \
|
{ \
|
||||||
Logging::Log(message, Logging::LogLevel::Debug); \
|
Logging::Log(message, Logging::LogLevel::Debug); \
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define LOG_TRACE(message)
|
||||||
|
#define LOG_DEBUG(message)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOG_INFO(message) \
|
#define LOG_INFO(message) \
|
||||||
if (Logging::HasCallback() && Logging::GetLogLevel() <= Logging::LogLevel::Information) \
|
if (Logging::HasCallback() && Logging::GetLogLevel() <= Logging::LogLevel::Information) \
|
||||||
|
|||||||
Reference in New Issue
Block a user