meson option: with_spdlog

mangohud-subproject
FlightlessMango 8 months ago
parent 3a4a62369c
commit cc9d9b3526

@ -0,0 +1,31 @@
// This header is a replacement for the real spdlog.h.
// In the case that we don't link with spdlog, we use this header instead
// allowing us to compile anyway
#include <cstdint>
#ifdef SPDLOG_INFO
#undef SPDLOG_INFO
#endif
#define SPDLOG_INFO(...)
#ifdef SPDLOG_DEBUG
#undef SPDLOG_DEBUG
#endif
#define SPDLOG_DEBUG(...)
#ifdef SPDLOG_ERROR
#undef SPDLOG_ERROR
#endif
#define SPDLOG_ERROR(...)
#ifdef SPDLOG_WARN
#undef SPDLOG_WARN
#endif
#define SPDLOG_WARN(...)
#ifdef SPDLOG_TRACE
#undef SPDLOG_TRACE
#endif
#define SPDLOG_TRACE(...)
#define SPDLOG_OFF

@ -227,17 +227,23 @@ implot_dep = null_dep
implot_lib = static_library('nulllib', []) implot_lib = static_library('nulllib', [])
endif endif
spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog')) if get_option('with_spdlog').enabled()
if not spdlog_dep.found() pre_args += '-DSPDLOG'
spdlog_sp = subproject('spdlog', default_options: [ spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog'))
'default_library=static', if not spdlog_dep.found()
'compile_library=true', spdlog_sp = subproject('spdlog', default_options: [
'werror=false', 'default_library=static',
'tests=false', 'compile_library=true',
]) 'werror=false',
spdlog_dep = spdlog_sp.get_variable('spdlog_dep') 'tests=false',
])
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
else
spdlog_dep = dependency('spdlog', required: true)
endif
else else
spdlog_dep = dependency('spdlog', required: true) inc_common += include_directories('disable_spdlog')
spdlog_dep = null_dep
endif endif
if ['windows', 'mingw'].contains(host_machine.system()) if ['windows', 'mingw'].contains(host_machine.system())

@ -12,4 +12,4 @@ option('mangoapp', type: 'boolean', value : false)
option('mangohudctl', type: 'boolean', value : false) option('mangohudctl', type: 'boolean', value : false)
option('mangoapp_layer', type: 'boolean', value : false) option('mangoapp_layer', type: 'boolean', value : false)
option('tests', type: 'feature', value: 'auto', description: 'Run tests') option('tests', type: 'feature', value: 'auto', description: 'Run tests')
option('with_notify', type: 'feature', value: 'enabled') option('with_spdlog', type: 'feature', value: 'enabled')

@ -117,7 +117,7 @@ void imgui_create(void *ctx, const gl_wsi plat)
inited = true; inited = true;
if (!gladLoadGL()) if (!gladLoadGL())
spdlog::error("Failed to initialize OpenGL context, crash incoming"); SPDLOG_ERROR("Failed to initialize OpenGL context, crash incoming");
deviceName = (char*)glGetString(GL_RENDERER); deviceName = (char*)glGetString(GL_RENDERER);
// If we're running zink we want to rely on the vulkan loader for the hud instead. // If we're running zink we want to rely on the vulkan loader for the hud instead.

@ -1364,7 +1364,7 @@ void HudElements::sort_elements(const std::pair<std::string, std::string>& optio
ordered_functions.push_back({graphs, value}); ordered_functions.push_back({graphs, value});
else else
{ {
spdlog::error("Unrecognized graph type: {}", value); SPDLOG_ERROR("Unrecognized graph type: {}", value);
} }
} }
} }

@ -77,9 +77,6 @@ if is_unixy or cpp.get_id() == 'emscripten'
if cpp.get_id() != 'emscripten' if cpp.get_id() != 'emscripten'
vklayer_files += 'real_dlsym.cpp' vklayer_files += 'real_dlsym.cpp'
endif
if get_option('with_notify').enabled()
vklayer_files += 'notify.cpp' vklayer_files += 'notify.cpp'
endif endif

@ -4,9 +4,12 @@
#include <thread> #include <thread>
#include <condition_variable> #include <condition_variable>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
// This will be set if we are not using the spdlog library
#ifndef SPDLOG_OFF
#include <spdlog/cfg/env.h> #include <spdlog/cfg/env.h>
#include <spdlog/sinks/stdout_color_sinks.h> #include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/rotating_file_sink.h>
#endif
#include <filesystem.h> #include <filesystem.h>
// #include <sys/stat.h> // #include <sys/stat.h>
#include "overlay.h" #include "overlay.h"
@ -55,6 +58,7 @@ int current_preset;
void init_spdlog() void init_spdlog()
{ {
#ifndef SPDLOG_OFF
if (spdlog::get("MANGOHUD")) if (spdlog::get("MANGOHUD"))
return; return;
@ -89,7 +93,7 @@ void init_spdlog()
} }
} }
} }
#endif
} }
void FpsLimiter(struct fps_limit& stats){ void FpsLimiter(struct fps_limit& stats){
@ -459,6 +463,7 @@ static float get_ticker_limited_pos(float pos, float tw, float& left_limit, floa
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
void render_mpris_metadata(const struct overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing) void render_mpris_metadata(const struct overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing)
{ {
#ifndef SPDLOG_OFF
static const float overflow = 50.f /* 3333ms * 0.5 / 16.6667 / 2 (to edge and back) */; static const float overflow = 50.f /* 3333ms * 0.5 / 16.6667 / 2 (to edge and back) */;
if (meta.meta.valid) { if (meta.meta.valid) {
@ -519,6 +524,7 @@ void render_mpris_metadata(const struct overlay_params& params, mutexed_metadata
//ImGui::PopFont(); //ImGui::PopFont();
ImGui::PopStyleVar(); ImGui::PopStyleVar();
} }
#endif
} }
#endif #endif

Loading…
Cancel
Save