Hi, On 2023-03-13 11:04:32 -0700, Nathan Bossart wrote: > On Mon, Mar 13, 2023 at 07:27:18AM +0100, Peter Eisentraut wrote: > > I have committed it like this. > > I noticed that after 6a30027, if you don't have the OpenSSL headers > installed, 'meson setup' will fail: > > meson.build:1195:4: ERROR: C header 'openssl/ssl.h' not found > > Shouldn't "auto" cause Postgres to be built without OpenSSL if the required > headers are not present?
Yea. I found another thing: When dependency() found something, but the headers weren't present, ssl_int wouldn't exist. Maybe something like the attached? Greetings, Andres Freund
>From b8bd0200667bac16674e40e769a9fb4bc4f54306 Mon Sep 17 00:00:00 2001 From: Andres Freund <and...@anarazel.de> Date: Mon, 13 Mar 2023 13:11:37 -0700 Subject: [PATCH v1] meson: fix openssl detection issues in 6a30027 Reported-by: Nathan Bossart <nathandboss...@gmail.com> Discussion: https://postgr.es/m/20230313180432.GA246741@nathanxps13 --- meson.build | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 8208815c96c..2ebdf914c1b 100644 --- a/meson.build +++ b/meson.build @@ -1189,23 +1189,29 @@ if sslopt in ['auto', 'openssl'] # via pkg-config et al ssl = dependency('openssl', required: false) + # only meson >= 0.57 supports declare_dependency() in cc.has_function(), so + # we pass cc.find_library() results if necessary + ssl_int = [] # via library + headers if not ssl.found() ssl_lib = cc.find_library('ssl', dirs: test_lib_d, header_include_directories: postgres_inc, - has_headers: ['openssl/ssl.h', 'openssl/err.h']) + has_headers: ['openssl/ssl.h', 'openssl/err.h'], + required: openssl_required) crypto_lib = cc.find_library('crypto', dirs: test_lib_d, - header_include_directories: postgres_inc) - ssl_int = [ssl_lib, crypto_lib] - - ssl = declare_dependency(dependencies: ssl_int, - include_directories: postgres_inc) + required: openssl_required) + if ssl_lib.found() and crypto_lib.found() + ssl_int = [ssl_lib, crypto_lib] + ssl = declare_dependency(dependencies: ssl_int, include_directories: postgres_inc) + endif elif cc.has_header('openssl/ssl.h', args: test_c_args, dependencies: ssl, required: openssl_required) and \ cc.has_header('openssl/err.h', args: test_c_args, dependencies: ssl, required: openssl_required) ssl_int = [ssl] + else + ssl = not_found_dep endif if ssl.found() -- 2.38.0