@@ -620,33 +620,66 @@ gssapiopt = get_option('gssapi')
620
620
krb_srvtab= ''
621
621
have_gssapi= false
622
622
if not gssapiopt.disabled()
623
- gssapi= dependency (' krb5-gssapi' ,required :gssapiopt )
623
+ gssapi= dependency (' krb5-gssapi' ,required :false )
624
624
have_gssapi= gssapi.found()
625
625
626
+ if have_gssapi
627
+ gssapi_deps= [gssapi]
628
+ elif not have_gssapi
629
+ # Hardcoded lookup for gssapi. This is necessary as gssapi on windows does
630
+ # not install neither pkg-config nor cmake dependency information.
631
+ if host_system== ' windows'
632
+ is_64= cc.sizeof(' void *' ,args : test_c_args)== 8
633
+ if is_64
634
+ gssapi_search_libs= [' gssapi64' ,' krb5_64' ,' comerr64' ]
635
+ else
636
+ gssapi_search_libs= [' gssapi32' ,' krb5_32' ,' comerr32' ]
637
+ endif
638
+ else
639
+ gssapi_search_libs= [' gssapi_krb5' ]
640
+ endif
641
+
642
+ gssapi_deps= []
643
+ foreach libname : gssapi_search_libs
644
+ lib= cc.find_library (libname,dirs : test_lib_d,required :false )
645
+ if lib.found()
646
+ have_gssapi= true
647
+ gssapi_deps+= lib
648
+ endif
649
+ endforeach
650
+
651
+ if have_gssapi
652
+ # Meson before 0.57.0 did not support using check_header() etc with
653
+ # declare_dependency(). Thus the tests below use the library looked up
654
+ # above. Once we require a newer meson version, we can simplify.
655
+ gssapi= declare_dependency (dependencies : gssapi_deps)
656
+ endif
657
+ endif
658
+
626
659
if not have_gssapi
627
- elif cc.check_header(' gssapi/gssapi.h' ,dependencies :gssapi ,required :false ,
660
+ elif cc.check_header(' gssapi/gssapi.h' ,dependencies :gssapi_deps ,required :false ,
628
661
args : test_c_args,include_directories : postgres_inc)
629
662
cdata.set(' HAVE_GSSAPI_GSSAPI_H' ,1 )
630
- elif cc.check_header(' gssapi.h' ,dependencies :gssapi ,required : gssapiopt,
663
+ elif cc.check_header(' gssapi.h' ,dependencies :gssapi_deps ,required : gssapiopt,
631
664
args : test_c_args,include_directories : postgres_inc)
632
665
cdata.set(' HAVE_GSSAPI_H' ,1 )
633
666
else
634
667
have_gssapi= false
635
668
endif
636
669
637
670
if not have_gssapi
638
- elif cc.check_header(' gssapi/gssapi_ext.h' ,dependencies :gssapi ,required :false ,
671
+ elif cc.check_header(' gssapi/gssapi_ext.h' ,dependencies :gssapi_deps ,required :false ,
639
672
args : test_c_args,include_directories : postgres_inc)
640
673
cdata.set(' HAVE_GSSAPI_GSSAPI_EXT_H' ,1 )
641
- elif cc.check_header(' gssapi_ext.h' ,dependencies :gssapi ,required : gssapiopt,
674
+ elif cc.check_header(' gssapi_ext.h' ,dependencies :gssapi_deps ,required : gssapiopt,
642
675
args : test_c_args,include_directories : postgres_inc)
643
676
cdata.set(' HAVE_GSSAPI_EXT_H' ,1 )
644
677
else
645
678
have_gssapi= false
646
679
endif
647
680
648
681
if not have_gssapi
649
- elif cc.has_function(' gss_store_cred_into' ,dependencies :gssapi ,
682
+ elif cc.has_function(' gss_store_cred_into' ,dependencies :gssapi_deps ,
650
683
args : test_c_args,include_directories : postgres_inc)
651
684
cdata.set(' ENABLE_GSS' ,1 )
652
685
@@ -657,6 +690,11 @@ if not gssapiopt.disabled()
657
690
else
658
691
have_gssapi= false
659
692
endif
693
+
694
+ if not have_gssapiand gssapiopt.enabled()
695
+ error (' dependency lookup for gssapi failed' )
696
+ endif
697
+
660
698
endif
661
699
if not have_gssapi
662
700
gssapi= not_found_dep