diff '--color=auto' -ur onnxruntime-1.21.0.orig/cmake/external/onnxruntime_external_deps.cmake onnxruntime-1.21.0/cmake/external/onnxruntime_external_deps.cmake
--- onnxruntime-1.21.0.orig/cmake/external/onnxruntime_external_deps.cmake	2025-03-06 01:37:52.000000000 +0100
+++ onnxruntime-1.21.0/cmake/external/onnxruntime_external_deps.cmake	2025-03-08 13:59:04.556296057 +0100
@@ -33,16 +33,19 @@
 # ABSL should be included before protobuf because protobuf may use absl
 include(external/abseil-cpp.cmake)
 
-set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE)
-
-onnxruntime_fetchcontent_declare(
-    re2
-    URL ${DEP_URL_re2}
-    URL_HASH SHA1=${DEP_SHA1_re2}
-    EXCLUDE_FROM_ALL
-    FIND_PACKAGE_ARGS NAMES re2
-)
-onnxruntime_fetchcontent_makeavailable(re2)
+include(FindPkgConfig)
+pkg_check_modules(re2 IMPORTED_TARGET re2)
+if (re2_FOUND)
+    add_library(re2::re2 ALIAS PkgConfig::re2)
+else()
+    set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE)
+    FetchContent_Declare(
+        re2
+        URL ${DEP_URL_re2}
+        URL_HASH SHA1=${DEP_SHA1_re2}
+        FIND_PACKAGE_ARGS NAMES re2
+    )
+endif()
 
 if (onnxruntime_BUILD_UNIT_TESTS)
   # WebAssembly threading support in Node.js is still an experimental feature and
