From: Aidar Imamov Subject: [PATCH] meson: expose OpenSSL and ICU compiler flags to PGXS-built extensions Some external dependencies have headers that are included by public server headers (e.g. libpq-be.h includes openssl/ssl.h). Extensions built with PGXS that include such headers need the dependency's compiler flags on the search path. The autoconf build picks these up from CPPFLAGS passed to configure (for OpenSSL) and from pkg-config's ICU_CFLAGS (for ICU); the meson build provided neither, so on systems where the dependency lives in a non-default prefix (e.g. Homebrew on macOS) such extensions failed to compile. --- src/include/meson.build | 25 ++++++++++++++++++++++++- src/makefiles/meson.build | 26 ++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/include/meson.build b/src/include/meson.build index 7d734d92dab..0340e3f7fd7 100644 --- a/src/include/meson.build +++ b/src/include/meson.build @@ -47,7 +47,30 @@ else var_cxx = 'g++' var_cxxflags = '' endif -var_cppflags = ' '.join(cppflags) + +pkg_config = find_program('pkg-config', required: false) + +# PGXS extensions that include libpq-be.h also pull in , so they +# need OpenSSL's compiler flags on the search path. +openssl_cppflags = [] +if ssl.found() + if ssl.type_name() == 'pkgconfig' and pkg_config.found() + openssl_cflags = run_command(pkg_config, '--cflags', 'openssl', + check: false).stdout().strip() + if openssl_cflags != '' + openssl_cppflags += openssl_cflags.split() + endif + elif ssl.type_name() == 'cmake' + foreach d : ssl.get_variable(cmake: 'OPENSSL_INCLUDE_DIR', + default_value: '').split(';') + if d.strip() != '' + openssl_cppflags += '-I' + d.strip() + endif + endforeach + endif +endif + +var_cppflags = ' '.join(cppflags + openssl_cppflags) var_cflags_sl = ' '.join(cc.get_supported_arguments('-fPIC')) # explicitly add -Wl,--as-needed, normally added by meson, but we want it for # PGXS compatibility diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build index 2401025d1cd..ec09674c1ce 100644 --- a/src/makefiles/meson.build +++ b/src/makefiles/meson.build @@ -137,6 +137,30 @@ else } endif +# ICU headers are pulled in by public server headers too, so extensions need +# ICU's compiler flags. Makefile.global adds $(ICU_CFLAGS) to CPPFLAGS. +icu_cflags = [] +if icu.found() + if icu.type_name() == 'pkgconfig' and pkg_config.found() + icu_cflags_out = run_command(pkg_config, '--cflags', 'icu-uc', + check: false).stdout().strip() + if icu_cflags_out != '' + icu_cflags += icu_cflags_out.split() + endif + elif icu.type_name() == 'cmake' + foreach d : icu.get_variable(cmake: 'ICU_INCLUDE_DIRS', + default_value: '').split(';') + if d.strip() != '' + icu_cflags += '-I' + d.strip() + endif + endforeach + endif +endif + +pgxs_kv += { + 'ICU_CFLAGS': ' '.join(icu_cflags), +} + pgxs_bins = { 'AR': find_program(['ar'], native: true, required: false), @@ -156,8 +180,6 @@ pgxs_bins = { } pgxs_empty = [ - 'ICU_CFLAGS', # needs to be added, included by public server headers - # hard to see why we'd need these ones? 'ZIC', 'TCLSH', -- 2.47.1