Skip to content

Commit 27b6799

Browse files
authored
build: Raise fmt auto-build version to 12.1, handle Windows flags (#5039)
Bump the version of 'fmt' library that we download and build (if not found) from 10.2 to 12.1. Some other touch-ups in build_fmt.cmake. Also, we have seen that recent fmt versions will fail to compile on MSVC unless using the `/utf-8` compiler flag, so ensure that is used and also passed on to other clients of libOpenImageIO_Util (which expose templates using those headers). Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 5e005e6 commit 27b6799

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/cmake/build_fmt.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# fmt by hand!
77
######################################################################
88

9-
set_cache (fmt_BUILD_VERSION 10.2.1 "fmt version for local builds")
9+
set_cache (fmt_BUILD_VERSION 12.1.0 "fmt version for local builds")
1010
set (fmt_GIT_REPOSITORY "https://github.com/fmtlib/fmt")
1111
set (fmt_GIT_TAG "${fmt_BUILD_VERSION}")
1212
# Note: fmt doesn't put "v" in front of version for its git tags
@@ -22,8 +22,6 @@ build_dependency_with_cmake(fmt
2222
-D FMT_TEST=OFF
2323
)
2424

25-
# Set some things up that we'll need for a subsequent find_package to work
26-
set (fmt_ROOT ${fmt_INSTALL_DIR})
27-
2825
# Signal to caller that we need to find again at the installed location
2926
set (fmt_REFIND TRUE)
27+
set (fmt_VERSION ${fmt_BUILD_VERSION})

src/libutil/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ function (setup_oiio_util_library targetname)
5151
target_link_options(${targetname} PRIVATE
5252
${${PROJECT_NAME}_link_options})
5353

54+
if (MSVC AND fmt_VERSION VERSION_GREATER_EQUAL 11.0)
55+
# For MSVC, Unicode support requires compiling with /utf-8, and fmt
56+
# needs this. This line adapted from fmt's CMakeLists.txt file.
57+
target_compile_options(${targetname} PUBLIC $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
58+
endif ()
59+
5460
target_include_directories (${targetname}
5561
PUBLIC
5662
$<BUILD_INTERFACE:${OpenImageIO_LOCAL_DEPS_ROOT}/include>

0 commit comments

Comments
 (0)