From 0d38fa2422d27fe2135c85b7bd1b7f95ba1598d5 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Tue, 30 May 2023 11:17:23 +0300 Subject: [PATCH] Externals: compile fmtlib as a library instead of using it with FMT_HEADER_ONLY --- extern/CMakeLists.txt | 1 + extern/fmtlib/CMakeLists.txt | 20 +++++++++ extern/fmtlib/README.blender | 8 +++- extern/fmtlib/src/format.cc | 43 +++++++++++++++++++ .../blender/editors/space_file/CMakeLists.txt | 1 + .../space_file/asset_catalog_tree_view.cc | 1 - source/blender/io/ply/CMakeLists.txt | 1 + .../io/ply/exporter/ply_file_buffer.hh | 1 - .../blender/io/wavefront_obj/CMakeLists.txt | 1 + .../wavefront_obj/exporter/obj_export_io.hh | 1 - 10 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 extern/fmtlib/CMakeLists.txt create mode 100644 extern/fmtlib/src/format.cc diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index d7d9b919127..df1ec79f663 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -3,6 +3,7 @@ # Libs that adhere to strict flags add_subdirectory(curve_fit_nd) +add_subdirectory(fmtlib) # Otherwise we get warnings here that we cant fix in external projects remove_strict_flags() diff --git a/extern/fmtlib/CMakeLists.txt b/extern/fmtlib/CMakeLists.txt new file mode 100644 index 00000000000..f5255b8a37b --- /dev/null +++ b/extern/fmtlib/CMakeLists.txt @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +set(INC + include +) + +set(INC_SYS +) + +set(SRC + include/fmt/core.h + include/fmt/format-inl.h + include/fmt/format.h + src/format.cc +) + +set(LIB +) + +blender_add_lib(extern_fmtlib "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/extern/fmtlib/README.blender b/extern/fmtlib/README.blender index 0f3b4be3e18..9c486ef2f75 100644 --- a/extern/fmtlib/README.blender +++ b/extern/fmtlib/README.blender @@ -4,5 +4,9 @@ License: MIT Upstream version: 10.0.0 (a0b8a92, 2023 May 10) Local modifications: -- Took only files needed for Blender: LICENSE, README and include/fmt - folder's core.h, format-inl.h, format.h +- Took only files needed for Blender: + - LICENSE, README + - include/fmt: core.h, format-inl.h, format.h + - src/format.cc +- CMakeLists.txt is not from fmtlib, but + made for Blender codebase diff --git a/extern/fmtlib/src/format.cc b/extern/fmtlib/src/format.cc new file mode 100644 index 00000000000..391d3a248c2 --- /dev/null +++ b/extern/fmtlib/src/format.cc @@ -0,0 +1,43 @@ +// Formatting library for C++ +// +// Copyright (c) 2012 - 2016, Victor Zverovich +// All rights reserved. +// +// For the license information refer to format.h. + +#include "fmt/format-inl.h" + +FMT_BEGIN_NAMESPACE +namespace detail { + +template FMT_API auto dragonbox::to_decimal(float x) noexcept + -> dragonbox::decimal_fp; +template FMT_API auto dragonbox::to_decimal(double x) noexcept + -> dragonbox::decimal_fp; + +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR +template FMT_API locale_ref::locale_ref(const std::locale& loc); +template FMT_API auto locale_ref::get() const -> std::locale; +#endif + +// Explicit instantiations for char. + +template FMT_API auto thousands_sep_impl(locale_ref) + -> thousands_sep_result; +template FMT_API auto decimal_point_impl(locale_ref) -> char; + +template FMT_API void buffer::append(const char*, const char*); + +template FMT_API void vformat_to(buffer&, string_view, + typename vformat_args<>::type, locale_ref); + +// Explicit instantiations for wchar_t. + +template FMT_API auto thousands_sep_impl(locale_ref) + -> thousands_sep_result; +template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t; + +template FMT_API void buffer::append(const wchar_t*, const wchar_t*); + +} // namespace detail +FMT_END_NAMESPACE diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index 575fa15eeb1..d5202d6d061 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -49,6 +49,7 @@ set(SRC set(LIB bf_blenkernel + extern_fmtlib ) if(WIN32) diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc index c00aff163fc..17b48bfaa72 100644 --- a/source/blender/editors/space_file/asset_catalog_tree_view.cc +++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc @@ -34,7 +34,6 @@ #include "file_intern.h" #include "filelist.h" -#define FMT_HEADER_ONLY #include using namespace blender; diff --git a/source/blender/io/ply/CMakeLists.txt b/source/blender/io/ply/CMakeLists.txt index 2d2518bc8fc..e2901228a07 100644 --- a/source/blender/io/ply/CMakeLists.txt +++ b/source/blender/io/ply/CMakeLists.txt @@ -55,6 +55,7 @@ set(SRC set(LIB bf_blenkernel bf_io_common + extern_fmtlib ) blender_add_lib(bf_ply "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/io/ply/exporter/ply_file_buffer.hh b/source/blender/io/ply/exporter/ply_file_buffer.hh index cf2dda58449..6ef3fd6014a 100644 --- a/source/blender/io/ply/exporter/ply_file_buffer.hh +++ b/source/blender/io/ply/exporter/ply_file_buffer.hh @@ -16,7 +16,6 @@ /* SEP macro from BLI path utils clashes with SEP symbol in fmt headers. */ #undef SEP -#define FMT_HEADER_ONLY #include namespace blender::io::ply { diff --git a/source/blender/io/wavefront_obj/CMakeLists.txt b/source/blender/io/wavefront_obj/CMakeLists.txt index 52d365cf794..5d7bbb1722d 100644 --- a/source/blender/io/wavefront_obj/CMakeLists.txt +++ b/source/blender/io/wavefront_obj/CMakeLists.txt @@ -58,6 +58,7 @@ set(SRC set(LIB bf_blenkernel bf_io_common + extern_fmtlib ) if(WITH_TBB) diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh index d632b959e54..d4c58865e4f 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh @@ -17,7 +17,6 @@ /* SEP macro from BLI path utils clashes with SEP symbol in fmt headers. */ #undef SEP -#define FMT_HEADER_ONLY #include namespace blender::io::obj {