meson: Fix support for empty darwin sysroot
authorPeter Eisentraut <[email protected]>
Mon, 27 Mar 2023 06:41:40 +0000 (08:41 +0200)
committerPeter Eisentraut <[email protected]>
Mon, 27 Mar 2023 07:11:08 +0000 (09:11 +0200)
The -isysroot options should only be added if the sysroot resolved to
a nonempty string.  This matches the behavior in src/template/darwin
(also documented in installation.sgml).

Discussion: https://www.postgresql.org/message-id/flat/60765bf0-5027-4b23-9f78-4a365d28823f%40enterprisedb.com

meson.build

index 2fe47a468c8c7ae2468f648eb163330c8c7112ce..61e94be8641f0dac7895464c0c9441f5d026aebb 100644 (file)
@@ -233,8 +233,10 @@ elif host_system == 'darwin'
   sysroot_args = [files('src/tools/darwin_sysroot'), get_option('darwin_sysroot')]
   pg_sysroot = run_command(sysroot_args, check:true).stdout().strip()
   message('darwin sysroot: @0@'.format(pg_sysroot))
-  cflags += ['-isysroot', pg_sysroot]
-  ldflags += ['-isysroot', pg_sysroot]
+  if pg_sysroot != ''
+    cflags += ['-isysroot', pg_sysroot]
+    ldflags += ['-isysroot', pg_sysroot]
+  endif
   # meson defaults to -Wl,-undefined,dynamic_lookup for modules, which we
   # don't want because a) it's different from what we do for autoconf, b) it
   # causes warnings starting in macOS Ventura