Saturday, July 06, 2024

UPDATE: ccache - fmt

Backport two commits to fix detection of newer fmt.


Index: patches/patch-cmake_FindFmt_cmake
===================================================================
RCS file: patches/patch-cmake_FindFmt_cmake
diff -N patches/patch-cmake_FindFmt_cmake
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-cmake_FindFmt_cmake 7 Jul 2024 03:00:02 -0000
@@ -0,0 +1,32 @@
+- build: Try harder to determine FMT_VERSION (#1478)
+ 71f772e9d3d4f8045cfa7bccd03bd21c1e8fbef1
+- build: Fix detection of Fmt version for Fmt<11
+ 3b09afc5f792f0bd0a15cf6b8408ea40eb069787
+
+Index: cmake/FindFmt.cmake
+--- cmake/FindFmt.cmake.orig
++++ cmake/FindFmt.cmake
+@@ -3,11 +3,20 @@ mark_as_advanced(FMT_INCLUDE_DIR FMT_LIBRARY)
+ if(DEP_FMT STREQUAL "BUNDLED")
+ message(STATUS "Using bundled Fmt as requested")
+ else()
+- find_path(FMT_INCLUDE_DIR fmt/core.h)
++ find_path(FMT_INCLUDE_DIR NAMES fmt/base.h fmt/core.h)
+ find_library(FMT_LIBRARY fmt)
+ if(FMT_INCLUDE_DIR AND FMT_LIBRARY)
+- file(READ "${FMT_INCLUDE_DIR}/fmt/core.h" _fmt_core_h)
+- string(REGEX MATCH "#define FMT_VERSION ([0-9]+)" _ "${_fmt_core_h}")
++ if(EXISTS "${FMT_INCLUDE_DIR}/fmt/base.h")
++ set(_fmt_h base.h)
++ else()
++ set(_fmt_h core.h)
++ endif()
++ file(READ "${FMT_INCLUDE_DIR}/fmt/${_fmt_h}" _fmt_h_content)
++ string(REGEX MATCH "#define FMT_VERSION ([0-9]+)" _ "${_fmt_h_content}")
++ if("${CMAKE_MATCH_0}" STREQUAL "")
++ message(FATAL_ERROR "FMT_VERSION not found")
++ return()
++ endif()
+ math(EXPR _fmt_major "${CMAKE_MATCH_1} / 10000")
+ math(EXPR _fmt_minor "${CMAKE_MATCH_1} / 100 % 100")
+ math(EXPR _fmt_patch "${CMAKE_MATCH_1} % 100")

No comments:

Post a Comment