@@ -1057,7 +1057,33 @@ else
1057
1057
build_options_config.set(' NO_ICONV' , ' 1' )
1058
1058
endif
1059
1059
1060
- pcre2 = dependency (' libpcre2-8' , required : get_option (' pcre2' ), default_options : [' default_library=static' , ' test=false' ])
1060
+ # can't use enable_auto_if() because it is only available in meson 1.1
1061
+ if host_machine .system() == ' windows' and get_option (' pcre2' ).allowed()
1062
+ pcre2_feature = true
1063
+ else
1064
+ pcre2_feature = get_option (' pcre2' )
1065
+ endif
1066
+ pcre2 = dependency (' libpcre2-8' , required : pcre2_feature, default_options : [' default_library=static' , ' test=false' ])
1067
+ if pcre2.found() and pcre2.type_name() != ' internal' and host_machine .system() == ' darwin'
1068
+ # macOS installs a broken system package, double check
1069
+ if not compiler.has_header(' pcre2.h' , dependencies : pcre2)
1070
+ if pcre2_feature.enabled()
1071
+ pcre2_fallback = [' pcre2' , ' libpcre2_8' ]
1072
+ else
1073
+ pcre2_fallback = []
1074
+ endif
1075
+ # Attempt to fallback or replace with not-found-dependency
1076
+ pcre2 = dependency ('' , required : false , fallback : pcre2_fallback, default_options : [' default_library=static' , ' test=false' ])
1077
+ if not pcre2.found()
1078
+ if pcre2_feature.enabled()
1079
+ error (' only a broken pcre2 install found and pcre2 is required' )
1080
+ else
1081
+ warning (' broken pcre2 install found, disabling pcre2 feature' )
1082
+ endif
1083
+ endif
1084
+ endif
1085
+ endif
1086
+
1061
1087
if pcre2.found()
1062
1088
libgit_dependencies += pcre2
1063
1089
libgit_c_args += ' -DUSE_LIBPCRE2'
0 commit comments