]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
build: Try harder to determine FMT_VERSION (#1478)
authorHolger Hoffstätte <holger@applied-asynchrony.com>
Tue, 2 Jul 2024 13:46:44 +0000 (15:46 +0200)
committerGitHub <noreply@github.com>
Tue, 2 Jul 2024 13:46:44 +0000 (15:46 +0200)
fmt-11.0 moved the FMT_VERSION from core.h to base.h, so try the
new header first and then fall back to the old one.

Closes: #1477
cmake/FindFmt.cmake

index 55126a3172d5da219fed73e0fbfe6de65f85c679..0619f4615ef05feaaf0f82c1aed328a42b659d89 100644 (file)
@@ -3,11 +3,19 @@ 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 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}")
+    file(READ "${FMT_INCLUDE_DIR}/fmt/base.h" _fmt_base_h)
+    string(REGEX MATCH "#define FMT_VERSION ([0-9]+)" _ "${_fmt_base_h}")
+    if("${CMAKE_MATCH_0}" STREQUAL "")
+      file(READ "${FMT_INCLUDE_DIR}/fmt/core.h" _fmt_core_h)
+      string(REGEX MATCH "#define FMT_VERSION ([0-9]+)" _ "${_fmt_core_h}")
+    endif()
+    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")