Skip to content

Commit 8dbf427

Browse files
committed
read fmt version from fmt/core.h
Signed-off-by: Dominik Wójt <[email protected]>
1 parent 2813308 commit 8dbf427

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/cmake/externalpackages.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,12 @@ macro (find_or_download_fmt)
350350
endif ()
351351
set (FMT_INCLUDE_DIR "${FMT_INSTALL_DIR}/include")
352352
set (OIIO_USING_FMT_LOCAL TRUE)
353-
set (fmt_VERSION ${BUILD_FMT_VERSION})
353+
file (STRINGS "${FMT_INCLUDE_DIR}/fmt/core.h" TMP REGEX "^#define FMT_VERSION .*$")
354+
string (REGEX MATCHALL "[0-9]+" FMT_VERSION_NUMERIC ${TMP})
355+
math(EXPR FMT_VERSION_PATCH "${FMT_VERSION_NUMERIC} % 100")
356+
math(EXPR FMT_VERSION_MINOR "(${FMT_VERSION_NUMERIC} / 100) % 100")
357+
math(EXPR FMT_VERSION_MAJOR "${FMT_VERSION_NUMERIC} / 10000")
358+
set (fmt_VERSION "${FMT_VERSION_MAJOR}.${FMT_VERSION_MINOR}.${FMT_VERSION_PATCH}")
354359
else ()
355360
get_target_property(FMT_INCLUDE_DIR fmt::fmt-header-only INTERFACE_INCLUDE_DIRECTORIES)
356361
set (OIIO_USING_FMT_LOCAL FALSE)

0 commit comments

Comments
 (0)