[libfmt] Require libfmt-7.1.0 or later in order to use a system-wide version.

- libfmt-6.2.0: Introduced the 'L' format specifier.
  - Previously, 'n' was available.
  - The 'L' specifier matches C++20 std::format().
- libfmt-7.0.x: Has fixes for the 'L' format specifier; removed 'n'.
  - 'n' can be re-enabled with FMT_DEPRECATED_N_SPECIFIER.
- libfmt-7.1.0: Has more fixes for the 'L' format specifier.
- libfmt-8.0.0: Removes the 'n' format specifier entirely.

Since we use the 'L' specifier, we will set a minimum of libfmt-7.1.0.
Ubuntu 20.04 has libfmt-6.1.2; Ubuntu 22.04 has libfmt-8.1.1.
Also, Ubuntu 20.04's libfmt is a static library. It was changed
to a shared library sometime between 20.04 and 22.04.

rp-libfmt.h: Removed macros for compatibility with versions of libfmt
older than 7.1.0.
This commit is contained in:
David Korth 2025-01-23 21:54:31 -05:00
parent ddbd5ca03d
commit 02a55c2dad
2 changed files with 17 additions and 19 deletions

View File

@ -11,7 +11,19 @@ IF(NOT USE_INTERNAL_FMT)
ENDIF()
# Check for libfmt.
FIND_PACKAGE(Fmt)
# - libfmt-6.2.0: Introduced the 'L' format specifier.
# - Previously, 'n' was available.
# - The 'L' specifier matches C++20 std::format().
# - libfmt-7.0.x: Has fixes for the 'L' format specifier; removed 'n'.
# - 'n' can be re-enabled with FMT_DEPRECATED_N_SPECIFIER.
# - libfmt-7.1.0: Has more fixes for the 'L' format specifier.
# - libfmt-8.0.0: Removes the 'n' format specifier entirely.
#
# Since we use the 'L' specifier, we will set a minimum of libfmt-7.1.0.
# Ubuntu 20.04 has libfmt-6.1.2; Ubuntu 22.04 has libfmt-8.1.1.
# Also, Ubuntu 20.04's libfmt is a static library. It was changed
# to a shared library sometime between 20.04 and 22.04.
FIND_PACKAGE(Fmt 7.1.0)
IF(Fmt_FOUND)
# Found system libfmt.
SET(HAVE_Fmt 1)

View File

@ -10,22 +10,13 @@
#ifdef __cplusplus
// libfmt [5.2.0, 7.0.0): Requires FMT_STRING_ALIAS=1.
// NOTE: We have to define this before including <fmt/format.h>,
// so it's defined unconditionally, regardless of libfmt version.
#define FMT_STRING_ALIAS 1
// Base libfmt header
#include <fmt/format.h>
// FMT_STRING() prior to libfmt-7.0.0 was handled differently.
#if FMT_VERSION < 40000
// libfmt 4.x and older: No compile-time format checks.
# define FMT_STRING(x) x
#elif FMT_VERSION < 70000
// libfmt [5.0.0, 7.0.0): fmt() macro
# define FMT_STRING(x) fmt(x)
#endif
// libfmt-7.1.0 is required.
#if FMT_VERSION < 70100
# error libfmt-7.1.0 or later is required!
#endif /* FMT_VERSION < 70100 */
// Our own FSTR() macro
#define FSTR(x) FMT_STRING(x)
@ -37,9 +28,4 @@
# endif /* FMT_VERSION >= 80000 */
#endif /* _WIN32 */
// libfmt-4.x: fmt::to_string() is in string.h.
#if FMT_VERSION >= 40000 && FMT_VERSION < 50000
# inculde <fmt/string.h>
#endif /* FMT_VERSION >= 40000 && FMT_VERSION < 50000 */
#endif /* __cplusplus */