meson: Allow toggling internal/system PCRE dependency

We don't always want to build GLib with a dependency on the system's
PCRE. The Autotools build allows this, and so should the Meson build.
This commit is contained in:
Emmanuele Bassi 2017-07-21 14:03:05 +01:00
parent 8962736ba9
commit bfd307855b
3 changed files with 11 additions and 4 deletions

View File

@ -4,7 +4,7 @@ configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h',
configuration : glibconfig_conf)
subdir('libcharset')
if not pcre.found()
if not use_system_pcre
subdir('pcre')
endif

View File

@ -1339,8 +1339,14 @@ else
error('No iconv() implementation found in C library or libiconv')
endif
pcre = dependency('libpcre', required : false) # Should check for Unicode support, too. FIXME
glib_conf.set('USE_SYSTEM_PCRE', pcre.found())
if get_option('with-pcre') == 'internal'
pcre = []
use_system_pcre = false
else
pcre = dependency('libpcre', required : false) # Should check for Unicode support, too. FIXME
use_system_pcre = pcre.found()
endif
glib_conf.set('USE_SYSTEM_PCRE', use_system_pcre)
libm = cc.find_library('m', required : false)
libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep'])
@ -1401,7 +1407,7 @@ endif
if libiconv.length() != 0
glib_conf.set('ICONV_LIBS', '-liconv')
endif
if pcre.found()
if use_system_pcre
glib_conf.set('PCRE_LIBS', '-lpcre')
endif
if libmount_dep.length() == 1 and libmount_dep[0].found()

View File

@ -1,5 +1,6 @@
option('with-docs', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
option('with-man', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
option('with-pcre', type : 'combo', choices : ['system', 'internal'], value : 'system')
option('enable-libmount', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'yes')
option('enable-dtrace', type : 'boolean', value : false,
description : 'include tracing support for dtrace')