--- a/glib/meson.build
+++ b/glib/meson.build
-@@ -402,6 +402,7 @@ pcre2_static_args = []
+@@ -400,8 +400,9 @@ endif
- if use_pcre2_static_flag
+ pcre2_static_args = []
+
+-if use_pcre2_static_flag
++if pcre2.type_name() == 'internal'
pcre2_static_args = ['-DPCRE2_STATIC']
+ pcre2 = pcre2.as_link_whole()
endif