mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
21b20712a3
The commit cd5808eb
introduced a union as a storage for the format
argument passed to the internal API fmt::detail::make_arg. This was done
to solve the issue that the internal API no longer accepted temporary
variables.
However, it's generally better to avoid using internal APIs, as they are
more likely to have breaking changes in the future. Instead, we can use
the public API fmt::dynamic_format_arg_store to dynamically build the
argument list. This API accepts temporary variables, and its behavior is
more stable than the internal API. `libfmt.cmake` is updated to reflect
the change as well.
All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
53 lines
1.6 KiB
CMake
53 lines
1.6 KiB
CMake
INCLUDE (CheckCXXSourceRuns)
|
|
INCLUDE (ExternalProject)
|
|
|
|
SET(WITH_LIBFMT "auto" CACHE STRING
|
|
"Which libfmt to use (possible values are 'bundled', 'system', or 'auto')")
|
|
|
|
MACRO(BUNDLE_LIBFMT)
|
|
SET(dir "${CMAKE_BINARY_DIR}/extra/libfmt")
|
|
SET(LIBFMT_INCLUDE_DIR "${dir}/src/libfmt/include")
|
|
|
|
IF(CMAKE_VERSION VERSION_GREATER "3.0")
|
|
SET(fmt_byproducts BUILD_BYPRODUCTS ${LIBFMT_INCLUDE_DIR}/fmt/format-inl.h)
|
|
ENDIF()
|
|
|
|
ExternalProject_Add(
|
|
libfmt
|
|
PREFIX "${dir}"
|
|
URL "https://github.com/fmtlib/fmt/releases/download/11.0.1/fmt-11.0.1.zip"
|
|
URL_MD5 5f3915e2eff60e7f70c558120592100d
|
|
INSTALL_COMMAND ""
|
|
CONFIGURE_COMMAND ""
|
|
BUILD_COMMAND ""
|
|
${fmt_byproducts}
|
|
)
|
|
ENDMACRO()
|
|
|
|
MACRO (CHECK_LIBFMT)
|
|
IF(WITH_LIBFMT STREQUAL "system" OR WITH_LIBFMT STREQUAL "auto")
|
|
SET(CMAKE_REQUIRED_INCLUDES ${LIBFMT_INCLUDE_DIR})
|
|
CHECK_CXX_SOURCE_RUNS(
|
|
"#define FMT_STATIC_THOUSANDS_SEPARATOR ','
|
|
#define FMT_HEADER_ONLY 1
|
|
#include <fmt/args.h>
|
|
int main() {
|
|
using ArgStore= fmt::dynamic_format_arg_store<fmt::format_context>;
|
|
ArgStore arg_store;
|
|
int answer= 4321;
|
|
arg_store.push_back(answer);
|
|
return fmt::vformat(\"{:L}\", arg_store).compare(\"4,321\");
|
|
}" HAVE_SYSTEM_LIBFMT)
|
|
SET(CMAKE_REQUIRED_INCLUDES)
|
|
ENDIF()
|
|
IF(NOT HAVE_SYSTEM_LIBFMT OR WITH_LIBFMT STREQUAL "bundled")
|
|
IF (WITH_LIBFMT STREQUAL "system")
|
|
MESSAGE(FATAL_ERROR "system libfmt library is not found or unusable")
|
|
ENDIF()
|
|
BUNDLE_LIBFMT()
|
|
ELSE()
|
|
FIND_FILE(Libfmt_core_h fmt/core.h) # for build_depends.cmake
|
|
ENDIF()
|
|
ENDMACRO()
|
|
|
|
MARK_AS_ADVANCED(LIBFMT_INCLUDE_DIR)
|