--- fmt-11.2.0/CMakeLists.txt.orig	2025-05-23 14:53:51.718314300 +0300
+++ fmt-11.2.0/CMakeLists.txt	2025-05-23 14:55:25.789870100 +0300
@@ -357,6 +357,9 @@
 
 if (BUILD_SHARED_LIBS)
   target_compile_definitions(fmt PRIVATE FMT_LIB_EXPORT INTERFACE FMT_SHARED)
+  set (target_suffix "shared")
+else ()
+  set (target_suffix "static")
 endif ()
 if (FMT_SAFE_DURATION_CAST)
   target_compile_definitions(fmt PUBLIC FMT_SAFE_DURATION_CAST)
@@ -393,7 +396,7 @@
   set(version_config ${PROJECT_BINARY_DIR}/fmt-config-version.cmake)
   set(project_config ${PROJECT_BINARY_DIR}/fmt-config.cmake)
   set(pkgconfig ${PROJECT_BINARY_DIR}/fmt.pc)
-  set(targets_export_name fmt-targets)
+  set(targets_export_name fmt-${target_suffix}-targets)
 
   set_verbose(FMT_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING
               "Installation directory for libraries, a relative path that "
--- fmt-11.2.0/support/cmake/fmt-config.cmake.in.orig	2025-05-23 14:56:11.879781000 +0300
+++ fmt-11.2.0/support/cmake/fmt-config.cmake.in	2025-05-23 14:57:14.931097700 +0300
@@ -1,7 +1,59 @@
 @PACKAGE_INIT@
 
-if (NOT TARGET fmt::fmt)
-  include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
+set(fmt_known_comps static shared)
+set(fmt_comp_static NO)
+set(fmt_comp_shared NO)
+foreach (fmt_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
+    if (fmt_comp IN_LIST fmt_known_comps)
+        set(fmt_comp_${fmt_comp} YES)
+    else ()
+        set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
+            "fmt does not recognize component `${fmt_comp}`.")
+        set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+        return()
+    endif ()
+endforeach ()
+
+if (fmt_comp_static AND fmt_comp_shared)
+    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
+        "fmt `static` and `shared` components are mutually exclusive.")
+    set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+    return()
+endif ()
+
+set(fmt_static_targets "${CMAKE_CURRENT_LIST_DIR}/fmt-static-targets.cmake")
+set(fmt_shared_targets "${CMAKE_CURRENT_LIST_DIR}/fmt-shared-targets.cmake")
+
+macro(fmt_load_targets type)
+    if (NOT EXISTS "${fmt_${type}_targets}")
+        set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
+            "fmt `${type}` libraries were requested but not found.")
+        set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
+        return()
+    endif ()
+    include("${fmt_${type}_targets}")
+endmacro()
+
+if (fmt_comp_static)
+    fmt_load_targets(static)
+elseif (fmt_comp_shared)
+    fmt_load_targets(shared)
+elseif (DEFINED fmt_SHARED_LIBS AND fmt_SHARED_LIBS)
+    fmt_load_targets(shared)
+elseif (DEFINED fmt_SHARED_LIBS AND NOT fmt_SHARED_LIBS)
+    fmt_load_targets(static)
+elseif (BUILD_SHARED_LIBS)
+    if (EXISTS "${fmt_shared_targets}")
+        fmt_load_targets(shared)
+    else ()
+        fmt_load_targets(static)
+    endif ()
+else ()
+    if (EXISTS "${fmt_static_targets}")
+        fmt_load_targets(static)
+    else ()
+        fmt_load_targets(shared)
+    endif ()
 endif ()
 
 check_required_components(fmt)
