diff --git a/third_party/harfbuzz/BUILD.gn b/third_party/harfbuzz/BUILD.gn
index a323852..2cb50f6 100644
--- a/third_party/harfbuzz/BUILD.gn
+++ b/third_party/harfbuzz/BUILD.gn
@@ -3,6 +3,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("../../gn/pkg_config.gni")
 import("../../gn/skia.gni")
 import("../third_party.gni")
 
@@ -11,13 +12,15 @@ declare_args() {
 }
 
 if (skia_use_system_harfbuzz) {
-  system("harfbuzz") {
-    include_dirs = [ "/usr/include/harfbuzz" ]
-    libs = [ "harfbuzz" ]
+  pkg_config("system_harfbuzz") {
+    packages = [ "harfbuzz" ]
     if (skia_pdf_subset_harfbuzz) {
-      libs += [ "harfbuzz-subset" ]
+      packages += [ "harfbuzz-subset" ]
     }
   }
+  source_set("harfbuzz") {
+      public_configs = [ ":system_harfbuzz" ]
+  }
 } else {
   third_party("harfbuzz") {
     _src = "../externals/harfbuzz/src"
diff --git a/third_party/icu/BUILD.gn b/third_party/icu/BUILD.gn
index 5f12870..f5c8124 100644
--- a/third_party/icu/BUILD.gn
+++ b/third_party/icu/BUILD.gn
@@ -3,14 +3,49 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("../../gn/pkg_config.gni")
 import("../../gn/skia.gni")
 import("../third_party.gni")
 import("icu.gni")
 
 if (skia_use_system_icu) {
-  system("icu") {
-    libs = [ "icuuc" ]
+  pkg_config("system_icui18n") {
+    packages = [ "icu-i18n" ]
+  }
+  pkg_config("system_icuuc") {
+    packages = [ "icu-uc" ]
+  }
+
+  group("icu") {
+    public_deps = [
+      ":icui18n",
+      ":icuuc",
+    ]
+  }
+
+  config("icu_config") {
     defines = [ "U_USING_ICU_NAMESPACE=0" ]
+    if (is_mingw) {
+      defines += [ "UCHAR_TYPE=wchar_t" ]
+    } else {
+      defines += [ "UCHAR_TYPE=uint16_t" ]
+    }
+  }
+
+  source_set("icui18n") {
+    public_configs = [
+      ":icu_config",
+      ":system_icui18n",
+    ]
+  }
+  source_set("icuuc") {
+    public_configs = [
+      ":icu_config",
+      ":system_icuuc",
+    ]
+  }
+  source_set("icudata") {
+    public_configs = [ ":icu_config" ]
   }
 } else {
   if (target_cpu == "wasm") {
