Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (NOT @OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH@ AND NOT OPENIMAGEIO_CONFIG_DO_NOT
HINTS @Imath_DIR@)
endif ()

if (NOT @fmt_LOCAL_BUILD@ AND NOT @OIIO_INTERNALIZE_FMT@)
if (NOT @fmt_LOCAL_BUILD@ AND (NOT @OIIO_INTERNALIZE_FMT@ OR @OIIO_USE_COMPILED_FMT@))
find_dependency(fmt)
endif ()

Expand Down
12 changes: 11 additions & 1 deletion src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,21 @@ checked_find_package (Robinmap REQUIRED

# fmtlib
set_option (OIIO_INTERNALIZE_FMT "Copy fmt headers into <install>/include/OpenImageIO/detail/fmt" ON)
set_option (OIIO_USE_COMPILED_FMT "Link against compiled fmt::fmt instead of header-only fmt" OFF)
if (OIIO_USE_COMPILED_FMT)
set (OIIO_USE_COMPILED_FMT_VALUE 1)
else ()
set (OIIO_USE_COMPILED_FMT_VALUE 0)
endif ()
checked_find_package (fmt REQUIRED
VERSION_MIN 9.0
BUILD_LOCAL missing
)
get_target_property(FMT_INCLUDE_DIR fmt::fmt-header-only INTERFACE_INCLUDE_DIRECTORIES)
if (OIIO_USE_COMPILED_FMT)
get_target_property(FMT_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES)
else ()
get_target_property(FMT_INCLUDE_DIR fmt::fmt-header-only INTERFACE_INCLUDE_DIRECTORIES)
endif ()


###########################################################################
Expand Down
12 changes: 9 additions & 3 deletions src/include/OpenImageIO/detail/fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
#include <OpenImageIO/platform.h>
#include <OpenImageIO/type_traits.h>

// We want the header-only implementation of fmt
#ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
// By default OIIO uses the header-only implementation of fmt. Builds that opt
// into compiled external fmt must use the same mode in OIIO and consumers.
#ifndef OIIO_USE_COMPILED_FMT
# define OIIO_USE_COMPILED_FMT 0
#endif
#if !OIIO_USE_COMPILED_FMT
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
#endif

#if OIIO_VERSION_LESS(3, 1, 2)
Expand Down
1 change: 1 addition & 0 deletions src/include/OpenImageIO/oiioversion.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#define OIIO_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define OIIO_VERSION_TWEAK @PROJECT_VERSION_TWEAK@
#define OIIO_VERSION_RELEASE_TYPE @PROJECT_VERSION_RELEASE_TYPE@
#define OIIO_USE_COMPILED_FMT @OIIO_USE_COMPILED_FMT_VALUE@

// Preprocessor utility: stringize
#define OIIO_STRINGIZE_HELPER(a) #a
Expand Down
6 changes: 5 additions & 1 deletion src/libutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ function (setup_oiio_util_library targetname)

if (OIIO_INTERNALIZE_FMT OR fmt_LOCAL_BUILD)
add_dependencies(${targetname} fmt_internal_target)
else ()
endif ()
if (OIIO_USE_COMPILED_FMT)
target_link_libraries (${targetname}
PUBLIC fmt::fmt)
elseif (NOT OIIO_INTERNALIZE_FMT AND NOT fmt_LOCAL_BUILD)
target_link_libraries (${targetname}
PUBLIC fmt::fmt-header-only)
endif ()
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ ustring::make_unique(string_view strref)
std::string s = Strutil::escape_chars(strref);
print(stderr, "IDEMPOTENT RE-HASH! |{}|\n", s);
for (auto c : s)
print(stderr, c > 0 ? "{:c}" : "\\{:03o}",
print(stderr, fmt::runtime(c > 0 ? "{:c}" : "\\{:03o}"),
static_cast<unsigned char>(c));
print(stderr, "\n");
# endif
Expand Down
Loading