From a9a4cad97b6dad8309a9b4f37a04528dd21c0964 Mon Sep 17 00:00:00 2001 From: Marco Clemencic <marco.clemencic@cern.ch> Date: Thu, 1 Jun 2023 18:04:54 +0200 Subject: [PATCH] Fix compilation with fmtlib < 8 --- .../src/MessageSvc/MessageSvcSink.cpp | 9 +++++++ GaudiKernel/CMakeLists.txt | 1 + .../Gaudi/Accumulators/HistogramArray.h | 5 +--- GaudiKernel/src/Lib/HistogramArray.cpp | 25 +++++++++++++++++++ GaudiKernel/src/Util/genconf.cpp | 9 +++++++ 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 GaudiKernel/src/Lib/HistogramArray.cpp diff --git a/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp b/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp index 407198463..831a272d9 100644 --- a/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp +++ b/GaudiCoreSvc/src/MessageSvc/MessageSvcSink.cpp @@ -21,6 +21,15 @@ #include <map> #include <string_view> +#if FMT_VERSION < 80000 +namespace fmt { + template <typename T> + const T& runtime( const T& v ) { + return v; + } +} // namespace fmt +#endif + namespace { /** diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 3eb3010db..9a23a87e4 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -79,6 +79,7 @@ gaudi_add_library(GaudiKernel src/Lib/GaudiMain.cpp src/Lib/Guards.cpp src/Lib/HistoDef.cpp + src/Lib/HistogramArray.cpp src/Lib/HistoryObj.cpp src/Lib/IChronoStatSvc.cpp src/Lib/IConversionSvc.cpp diff --git a/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h b/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h index 4004548c1..46c7b4850 100644 --- a/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h +++ b/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h @@ -11,9 +11,6 @@ #pragma once #include <Gaudi/Accumulators/Histogram.h> - -#include <fmt/format.h> - #include <utility> namespace Gaudi::Accumulators { @@ -27,7 +24,7 @@ namespace Gaudi::Accumulators { struct FormatHistDefault { std::string_view text; FormatHistDefault( std::string_view t ) : text{ t } {} - auto operator()( size_t n ) { return fmt::format( fmt::runtime( text ), n ); } + std::string operator()( size_t n ); }; /** diff --git a/GaudiKernel/src/Lib/HistogramArray.cpp b/GaudiKernel/src/Lib/HistogramArray.cpp new file mode 100644 index 000000000..880587d14 --- /dev/null +++ b/GaudiKernel/src/Lib/HistogramArray.cpp @@ -0,0 +1,25 @@ +/***********************************************************************************\ +* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * +* * +* This software is distributed under the terms of the Apache version 2 licence, * +* copied verbatim in the file "LICENSE". * +* * +* In applying this licence, CERN does not waive the privileges and immunities * +* granted to it by virtue of its status as an Intergovernmental Organization * +* or submit itself to any jurisdiction. * +\***********************************************************************************/ +#include <Gaudi/Accumulators/HistogramArray.h> +#include <fmt/format.h> + +#if FMT_VERSION < 80000 +namespace fmt { + template <typename T> + const T& runtime( const T& v ) { + return v; + } +} // namespace fmt +#endif + +std::string Gaudi::Accumulators::details::FormatHistDefault::operator()( size_t n ) { + return fmt::format( fmt::runtime( text ), n ); +} diff --git a/GaudiKernel/src/Util/genconf.cpp b/GaudiKernel/src/Util/genconf.cpp index 39700764f..86641f5db 100644 --- a/GaudiKernel/src/Util/genconf.cpp +++ b/GaudiKernel/src/Util/genconf.cpp @@ -69,6 +69,15 @@ #include <type_traits> #include <vector> +#if FMT_VERSION < 80000 +namespace fmt { + template <typename T> + const T& runtime( const T& v ) { + return v; + } +} // namespace fmt +#endif + namespace po = boost::program_options; namespace fs = boost::filesystem; -- GitLab