From 33958cd0f75205b7c0b758c3d1ae2d24ebc9e63a Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 19 Jul 2025 09:31:16 +0300 Subject: [PATCH] fmt: prefer system package if found mu embeds a "vendored" subset of the libfmt package under thirdparty; but it's better to use the system-package if the user has one. So, use the system package if found or user -Duse-embedded-fmt=true is specified. --- lib/utils/meson.build | 7 ++++--- lib/utils/mu-error.hh | 6 +----- lib/utils/mu-utils.hh | 5 +---- meson.build | 21 ++++++++++++++++++++- meson_options.txt | 14 ++++++++++++++ thirdparty/fmt/{ => fmt}/LICENSE | 0 thirdparty/fmt/{ => fmt}/args.h | 0 thirdparty/fmt/{ => fmt}/base.h | 0 thirdparty/fmt/{ => fmt}/chrono.h | 0 thirdparty/fmt/{ => fmt}/color.h | 0 thirdparty/fmt/{ => fmt}/compile.h | 0 thirdparty/fmt/{ => fmt}/core.h | 0 thirdparty/fmt/{ => fmt}/format-inl.h | 0 thirdparty/fmt/{ => fmt}/format.h | 0 thirdparty/fmt/{ => fmt}/os.h | 0 thirdparty/fmt/{ => fmt}/ostream.h | 0 thirdparty/fmt/{ => fmt}/printf.h | 0 thirdparty/fmt/{ => fmt}/ranges.h | 0 thirdparty/fmt/{ => fmt}/std.h | 0 thirdparty/fmt/{ => fmt}/xchar.h | 0 20 files changed, 40 insertions(+), 13 deletions(-) rename thirdparty/fmt/{ => fmt}/LICENSE (100%) rename thirdparty/fmt/{ => fmt}/args.h (100%) rename thirdparty/fmt/{ => fmt}/base.h (100%) rename thirdparty/fmt/{ => fmt}/chrono.h (100%) rename thirdparty/fmt/{ => fmt}/color.h (100%) rename thirdparty/fmt/{ => fmt}/compile.h (100%) rename thirdparty/fmt/{ => fmt}/core.h (100%) rename thirdparty/fmt/{ => fmt}/format-inl.h (100%) rename thirdparty/fmt/{ => fmt}/format.h (100%) rename thirdparty/fmt/{ => fmt}/os.h (100%) rename thirdparty/fmt/{ => fmt}/ostream.h (100%) rename thirdparty/fmt/{ => fmt}/printf.h (100%) rename thirdparty/fmt/{ => fmt}/ranges.h (100%) rename thirdparty/fmt/{ => fmt}/std.h (100%) rename thirdparty/fmt/{ => fmt}/xchar.h (100%) diff --git a/lib/utils/meson.build b/lib/utils/meson.build index 3263a94e..37bde7dd 100644 --- a/lib/utils/meson.build +++ b/lib/utils/meson.build @@ -1,4 +1,4 @@ -## Copyright (C) 2022-2023 Dirk-Jan C. Binnema +## Copyright (C) 2022-2025 Dirk-Jan C. Binnema ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -41,14 +41,15 @@ lib_mu_utils=static_library('mu-utils', gio_unix_dep, config_h_dep, readline_dep, - cld2_dep + cld2_dep, + fmt_dep ], include_directories: include_directories(['.', '..', thirdparty]), install: false) lib_mu_utils_dep = declare_dependency( link_with: lib_mu_utils, - compile_args: '-DFMT_HEADER_ONLY', + dependencies: [fmt_dep], include_directories: include_directories(['.', '..', thirdparty])) diff --git a/lib/utils/mu-error.hh b/lib/utils/mu-error.hh index 36b4178b..50719024 100644 --- a/lib/utils/mu-error.hh +++ b/lib/utils/mu-error.hh @@ -1,5 +1,5 @@ /* -** Copyright (C) 2019-2023 Dirk-Jan C. Binnema +** Copyright (C) 2019-2025 Dirk-Jan C. Binnema ** ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the @@ -28,10 +28,6 @@ #include "mu-utils.hh" #include -#ifndef FMT_HEADER_ONLY -#define FMT_HEADER_ONLY -#endif - #include #include diff --git a/lib/utils/mu-utils.hh b/lib/utils/mu-utils.hh index 8ec1f17a..c84d4b3c 100644 --- a/lib/utils/mu-utils.hh +++ b/lib/utils/mu-utils.hh @@ -1,5 +1,5 @@ /* -** Copyright (C) 2020-2023 Dirk-Jan C. Binnema +** Copyright (C) 2020-2025 Dirk-Jan C. Binnema ** ** This library is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public License @@ -36,9 +36,6 @@ #include "mu-option.hh" -#ifndef FMT_HEADER_ONLY -#define FMT_HEADER_ONLY -#endif /*FMT_HEADER_ONLY*/ #include #include #include diff --git a/meson.build b/meson.build index 19a5933b..a3721575 100644 --- a/meson.build +++ b/meson.build @@ -219,6 +219,26 @@ host_system = host_machine.system() # soft dependencies # +# use system's fmt if found, otherwise fall back to embedded version +# we can probably get away with a lower version, but want to have (roughly) +# the same in embedded / system. +fmt_dep = dependency('fmt', version: '>=11.1', required:false) +if not fmt_dep.found() or get_option('use-embedded-fmt') + message('using embedded fmt') + fmt_dep = declare_dependency( + include_directories : join_paths('.', 'thirdparty/fmt'), + compile_args: '-DFMT_HEADER_ONLY') +endif + +# use system's CLI11 if found, otherwise fall back to embedded version +cli11_dep = dependency('CLI11', version: '>=2.4', required:false) +if not cli11_dep.found() or get_option('use-embedded-cli11') + message('using embedded CLI11') + cli11_dep = declare_dependency( + compile_args: '-DUSE_EMBEDDED_CLI11', + include_directories : join_paths('.', 'thirdparty/cli11')) +endif + # # logging # @@ -280,7 +300,6 @@ if get_option('readline').enabled() config_h_data.set('HAVE_READLINE_HISTORY_H', 1) endif - ################################################################################ # write out version.texi (for texinfo builds in mu4e, guile) version_texi_data=configuration_data() diff --git a/meson_options.txt b/meson_options.txt index 35c74c96..1ef09b0f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -15,6 +15,20 @@ ## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# mu contains some 'vendored' dependencies under thirdparty/; those +# are only used if the corresponding system package is not found +# (if such exists). But, we can override: + +option('use-embedded-fmt', + type: 'boolean', + value: false, + description: 'Use the embedded fmt, even if system package is found') + +# +# language detection +# + option('cld2', type : 'feature', value: 'auto', diff --git a/thirdparty/fmt/LICENSE b/thirdparty/fmt/fmt/LICENSE similarity index 100% rename from thirdparty/fmt/LICENSE rename to thirdparty/fmt/fmt/LICENSE diff --git a/thirdparty/fmt/args.h b/thirdparty/fmt/fmt/args.h similarity index 100% rename from thirdparty/fmt/args.h rename to thirdparty/fmt/fmt/args.h diff --git a/thirdparty/fmt/base.h b/thirdparty/fmt/fmt/base.h similarity index 100% rename from thirdparty/fmt/base.h rename to thirdparty/fmt/fmt/base.h diff --git a/thirdparty/fmt/chrono.h b/thirdparty/fmt/fmt/chrono.h similarity index 100% rename from thirdparty/fmt/chrono.h rename to thirdparty/fmt/fmt/chrono.h diff --git a/thirdparty/fmt/color.h b/thirdparty/fmt/fmt/color.h similarity index 100% rename from thirdparty/fmt/color.h rename to thirdparty/fmt/fmt/color.h diff --git a/thirdparty/fmt/compile.h b/thirdparty/fmt/fmt/compile.h similarity index 100% rename from thirdparty/fmt/compile.h rename to thirdparty/fmt/fmt/compile.h diff --git a/thirdparty/fmt/core.h b/thirdparty/fmt/fmt/core.h similarity index 100% rename from thirdparty/fmt/core.h rename to thirdparty/fmt/fmt/core.h diff --git a/thirdparty/fmt/format-inl.h b/thirdparty/fmt/fmt/format-inl.h similarity index 100% rename from thirdparty/fmt/format-inl.h rename to thirdparty/fmt/fmt/format-inl.h diff --git a/thirdparty/fmt/format.h b/thirdparty/fmt/fmt/format.h similarity index 100% rename from thirdparty/fmt/format.h rename to thirdparty/fmt/fmt/format.h diff --git a/thirdparty/fmt/os.h b/thirdparty/fmt/fmt/os.h similarity index 100% rename from thirdparty/fmt/os.h rename to thirdparty/fmt/fmt/os.h diff --git a/thirdparty/fmt/ostream.h b/thirdparty/fmt/fmt/ostream.h similarity index 100% rename from thirdparty/fmt/ostream.h rename to thirdparty/fmt/fmt/ostream.h diff --git a/thirdparty/fmt/printf.h b/thirdparty/fmt/fmt/printf.h similarity index 100% rename from thirdparty/fmt/printf.h rename to thirdparty/fmt/fmt/printf.h diff --git a/thirdparty/fmt/ranges.h b/thirdparty/fmt/fmt/ranges.h similarity index 100% rename from thirdparty/fmt/ranges.h rename to thirdparty/fmt/fmt/ranges.h diff --git a/thirdparty/fmt/std.h b/thirdparty/fmt/fmt/std.h similarity index 100% rename from thirdparty/fmt/std.h rename to thirdparty/fmt/fmt/std.h diff --git a/thirdparty/fmt/xchar.h b/thirdparty/fmt/fmt/xchar.h similarity index 100% rename from thirdparty/fmt/xchar.h rename to thirdparty/fmt/fmt/xchar.h