Skip to content

Commit 557c494

Browse files
committed
Merge branch 'cb/meson-avoid-broken-macos-pcre2'
Build fix for macOS. * cb/meson-avoid-broken-macos-pcre2: meson: work around broken system PCRE2 dependency in macOS
2 parents 4f5b161 + 8c3add5 commit 557c494

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

meson.build

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,33 @@ else
10571057
build_options_config.set('NO_ICONV', '1')
10581058
endif
10591059

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+
10611087
if pcre2.found()
10621088
libgit_dependencies += pcre2
10631089
libgit_c_args += '-DUSE_LIBPCRE2'

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ option('gitweb', type: 'feature', value: 'auto',
4545
description: 'Build Git web interface. Requires Perl.')
4646
option('iconv', type: 'feature', value: 'auto',
4747
description: 'Support reencoding strings with different encodings.')
48-
option('pcre2', type: 'feature', value: 'enabled',
48+
option('pcre2', type: 'feature', value: 'auto',
4949
description: 'Support Perl-compatible regular expressions in e.g. git-grep(1).')
5050
option('perl', type: 'feature', value: 'auto',
5151
description: 'Build tools written in Perl.')

0 commit comments

Comments
 (0)