]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
build: Fix detection of Fmt version for Fmt<11
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 2 Jul 2024 15:05:43 +0000 (17:05 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 2 Jul 2024 18:23:21 +0000 (20:23 +0200)
Fixes regression in 71f772e9d3d4f8045cfa7bccd03bd21c1e8fbef1.

cmake/FindFmt.cmake

index 0619f4615ef05feaaf0f82c1aed328a42b659d89..7c39291eca2f0b0f69d76ef5aa65e80e3810798d 100644 (file)
@@ -3,15 +3,16 @@ 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/base.h 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/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}")
+    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()