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.
This commit is contained in:
Dirk-Jan C. Binnema
2025-07-19 09:31:16 +03:00
parent f90839b48b
commit 33958cd0f7
20 changed files with 40 additions and 13 deletions

View File

@ -1,4 +1,4 @@
## Copyright (C) 2022-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2022-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## 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]))

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2019-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2019-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 <glib.h>
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
#endif
#include <fmt/format.h>
#include <fmt/core.h>

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2020-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2020-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 <fmt/format.h>
#include <fmt/core.h>
#include <fmt/chrono.h>

View File

@ -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()

View File

@ -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',