summaryrefslogtreecommitdiff
path: root/kms++
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2026-04-30 09:35:03 +0300
committerTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2026-04-30 11:09:49 +0300
commitf9da4640c4098107aefc6c02b12b543384cccc50 (patch)
tree275e3dcc5a709be2e2367520a2fba294a191969f /kms++
parenta31ddfd9c4e294f29b9203463022d0eac11cecc5 (diff)
Drop libfmt
We can use std::format() and a custom print() wrapper with C++20. When moving to C++23, we can drop the wrapper. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Diffstat (limited to 'kms++')
-rw-r--r--kms++/inc/kms++/format.h28
-rw-r--r--kms++/meson.build2
-rw-r--r--kms++/src/videomode.cpp2
3 files changed, 30 insertions, 2 deletions
diff --git a/kms++/inc/kms++/format.h b/kms++/inc/kms++/format.h
new file mode 100644
index 0000000..b48babe
--- /dev/null
+++ b/kms++/inc/kms++/format.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <cstdio>
+#include <format>
+#include <string>
+
+// This can be removed when moving to C++23. For now, this gives us
+// fmt::format() and fmt::print().
+
+namespace fmt {
+
+using std::format;
+
+template<typename... Args>
+void print(std::format_string<Args...> fmtstr, Args&&... args)
+{
+ std::string s = std::format(fmtstr, std::forward<Args>(args)...);
+ std::fwrite(s.data(), 1, s.size(), stdout);
+}
+
+template<typename... Args>
+void print(std::FILE* f, std::format_string<Args...> fmtstr, Args&&... args)
+{
+ std::string s = std::format(fmtstr, std::forward<Args>(args)...);
+ std::fwrite(s.data(), 1, s.size(), f);
+}
+
+} // namespace fmt
diff --git a/kms++/meson.build b/kms++/meson.build
index cd7a494..4fb5fc9 100644
--- a/kms++/meson.build
+++ b/kms++/meson.build
@@ -68,7 +68,7 @@ else
omapdrm_enabled = false
endif
-libkmsxx_deps = [ libdrm_dep, libfmt_dep, libdrmomap_dep ]
+libkmsxx_deps = [ libdrm_dep, libdrmomap_dep ]
libkmsxx = library('kms++',
libkmsxx_sources,
diff --git a/kms++/src/videomode.cpp b/kms++/src/videomode.cpp
index 4be6de7..b7b1b28 100644
--- a/kms++/src/videomode.cpp
+++ b/kms++/src/videomode.cpp
@@ -2,7 +2,7 @@
#include <xf86drmMode.h>
#include <cmath>
#include <sstream>
-#include <fmt/format.h>
+#include <kms++/format.h>
#include <kms++/kms++.h>
#include "helpers.h"