postgres.git / summary / log / commit / refs
commit 2b4593379b818ee81193b113dab3acdc3191f08d
Author: Andres Freund <andres@anarazel.de>
Date: Sat Jul 20 20:51:09 2024 +0000
First released in: 18.0, 16.4, 17.0
meson: Add support for detecting gss without pkg-config
This is required as MIT Kerberos does provide neither pkg-config nor cmake
dependency information on windows.
Reported-by: Dave Page <dpage@pgadmin.org>
Reviewed-by: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/20240709065101.xhc74r3mdg2lmn4w@awork3.anarazel.de
Backpatch: 16-, where meson support was added
meson.build | 50 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 6 deletions(-)
diff --git a/meson.build b/meson.build
index c068d9a568b..a7bdf1cfc33 100644
--- a/meson.build
+++ b/meson.build
@@ -620,14 +620,47 @@ gssapiopt = get_option('gssapi')
krb_srvtab = ''
have_gssapi = false
if not gssapiopt.disabled()
- gssapi = dependency('krb5-gssapi', required: gssapiopt)
+ gssapi = dependency('krb5-gssapi', required: false)
have_gssapi = gssapi.found()
+ if have_gssapi
+ gssapi_deps = [gssapi]
+ elif not have_gssapi
+ # Hardcoded lookup for gssapi. This is necessary as gssapi on windows does
+ # not install neither pkg-config nor cmake dependency information.
+ if host_system == 'windows'
+ is_64 = cc.sizeof('void *', args: test_c_args) == 8
+ if is_64
+ gssapi_search_libs = ['gssapi64', 'krb5_64', 'comerr64']
+ else
+ gssapi_search_libs = ['gssapi32', 'krb5_32', 'comerr32']
+ endif
+ else
+ gssapi_search_libs = ['gssapi_krb5']
+ endif
+
+ gssapi_deps = []
+ foreach libname : gssapi_search_libs
+ lib = cc.find_library(libname, dirs: test_lib_d, required: false)
+ if lib.found()
+ have_gssapi = true
+ gssapi_deps += lib
+ endif
+ endforeach
+
+ if have_gssapi
+ # Meson before 0.57.0 did not support using check_header() etc with
+ # declare_dependency(). Thus the tests below use the library looked up
+ # above. Once we require a newer meson version, we can simplify.
+ gssapi = declare_dependency(dependencies: gssapi_deps)
+ endif
+ endif
+
if not have_gssapi
- elif cc.check_header('gssapi/gssapi.h', dependencies: gssapi, required: false,
+ elif cc.check_header('gssapi/gssapi.h', dependencies: gssapi_deps, required: false,
args: test_c_args, include_directories: postgres_inc)
cdata.set('HAVE_GSSAPI_GSSAPI_H', 1)
- elif cc.check_header('gssapi.h', dependencies: gssapi, required: gssapiopt,
+ elif cc.check_header('gssapi.h', dependencies: gssapi_deps, required: gssapiopt,
args: test_c_args, include_directories: postgres_inc)
cdata.set('HAVE_GSSAPI_H', 1)
else
@@ -635,10 +668,10 @@ if not gssapiopt.disabled()
endif
if not have_gssapi
- elif cc.check_header('gssapi/gssapi_ext.h', dependencies: gssapi, required: false,
+ elif cc.check_header('gssapi/gssapi_ext.h', dependencies: gssapi_deps, required: false,
args: test_c_args, include_directories: postgres_inc)
cdata.set('HAVE_GSSAPI_GSSAPI_EXT_H', 1)
- elif cc.check_header('gssapi_ext.h', dependencies: gssapi, required: gssapiopt,
+ elif cc.check_header('gssapi_ext.h', dependencies: gssapi_deps, required: gssapiopt,
args: test_c_args, include_directories: postgres_inc)
cdata.set('HAVE_GSSAPI_EXT_H', 1)
else
@@ -646,7 +679,7 @@ if not gssapiopt.disabled()
endif
if not have_gssapi
- elif cc.has_function('gss_store_cred_into', dependencies: gssapi,
+ elif cc.has_function('gss_store_cred_into', dependencies: gssapi_deps,
args: test_c_args, include_directories: postgres_inc)
cdata.set('ENABLE_GSS', 1)
@@ -657,6 +690,11 @@ if not gssapiopt.disabled()
else
have_gssapi = false
endif
+
+ if not have_gssapi and gssapiopt.enabled()
+ error('dependency lookup for gssapi failed')
+ endif
+
endif
if not have_gssapi
gssapi = not_found_dep
[parent: cc50694c8d96]