meson option: with_spdlog

mangohud-subproject
FlightlessMango 7 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', [])
endif
spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog'))
if not spdlog_dep.found()
spdlog_sp = subproject('spdlog', default_options: [
'default_library=static',
'compile_library=true',
'werror=false',
'tests=false',
])
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
if get_option('with_spdlog').enabled()
pre_args += '-DSPDLOG'
spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog'))
if not spdlog_dep.found()
spdlog_sp = subproject('spdlog', default_options: [
'default_library=static',
'compile_library=true',
'werror=false',
'tests=false',
])
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
else
spdlog_dep = dependency('spdlog', required: true)
endif
else
spdlog_dep = dependency('spdlog', required: true)
inc_common += include_directories('disable_spdlog')
spdlog_dep = null_dep
endif
if ['windows', 'mingw'].contains(host_machine.system())

@ -12,4 +12,4 @@ option('mangoapp', type: 'boolean', value : false)
option('mangohudctl', type: 'boolean', value : false)
option('mangoapp_layer', type: 'boolean', value : false)
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;
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);
// 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});
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'
vklayer_files += 'real_dlsym.cpp'
endif
if get_option('with_notify').enabled()
vklayer_files += 'notify.cpp'
endif

@ -4,9 +4,12 @@
#include <thread>
#include <condition_variable>
#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/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/rotating_file_sink.h>
#endif
#include <filesystem.h>
// #include <sys/stat.h>
#include "overlay.h"
@ -55,6 +58,7 @@ int current_preset;
void init_spdlog()
{
#ifndef SPDLOG_OFF
if (spdlog::get("MANGOHUD"))
return;
@ -89,7 +93,7 @@ void init_spdlog()
}
}
}
#endif
}
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
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) */;
if (meta.meta.valid) {
@ -519,6 +524,7 @@ void render_mpris_metadata(const struct overlay_params& params, mutexed_metadata
//ImGui::PopFont();
ImGui::PopStyleVar();
}
#endif
}
#endif

Loading…
Cancel
Save