system: Fix build with fmt==8.0 and C++20
Since fmt==8.0 the first argument of fmt::format is supposed to be
constexpr. If it is not constexpr, it is supposed to be wrapped inside
fmt:runtime [1,2].
[1] https://github.com/fmtlib/fmt/releases/tag/8.0.0
[2] https://github.com/fmtlib/fmt/issues/2421
Change-Id: I10424c4867b142955b61b9dc240a06d01dd204a5
diff --git a/src/system/Authentication.cpp b/src/system/Authentication.cpp
index 7391958..ae03088 100644
--- a/src/system/Authentication.cpp
+++ b/src/system/Authentication.cpp
@@ -138,7 +138,14 @@
std::string Authentication::authorizedKeysPath(const std::string& username)
{
using namespace fmt::literals;
- return fmt::format(m_authorized_keys_format, "USER"_a=username, "HOME"_a=homeDirectory(username));
+
+#if FMT_VERSION >= 80000 // fmt >= 8.0.0
+ auto str = fmt::runtime(m_authorized_keys_format);
+#else
+ auto str = m_authorized_keys_format;
+#endif
+
+ return fmt::format(str, "USER"_a=username, "HOME"_a=homeDirectory(username));
}
std::vector<std::string> Authentication::listKeys(const std::string& username)