From eccd941850e3e2ebdbf929cc1b1a573d1c4457cd Mon Sep 17 00:00:00 2001
From: Tristan Partin <tristan@neon.tech>
Date: Wed, 17 May 2023 09:44:49 -0500
Subject: [PATCH v2 14/17] Reduce branching on Meson version

This code had a branch depending on Meson version. Instead, we can just
move the system checks to the if statement. I believe this also keeps
selinux and systemd from being looked for on non-Linux systems when
using Meson < 0.59. Before they would be checked, but obviously fail.
---
 meson.build | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/meson.build b/meson.build
index 79b6aa47ec..4f13896473 100644
--- a/meson.build
+++ b/meson.build
@@ -1191,13 +1191,10 @@ endif
 ###############################################################
 
 selinux = not_found_dep
-selinuxopt = get_option('selinux')
-if meson.version().version_compare('>=0.59')
-  selinuxopt = selinuxopt.disable_auto_if(host_system != 'linux')
+if host_system == 'linux'
+  selinux = dependency('libselinux', required: get_option('selinux'), version: '>= 2.1.10')
+  cdata.set('HAVE_LIBSELINUX', selinux.found() ? 1 : false)
 endif
-selinux = dependency('libselinux', required: selinuxopt, version: '>= 2.1.10')
-cdata.set('HAVE_LIBSELINUX',
-  selinux.found() ? 1 : false)
 
 
 
@@ -1206,12 +1203,10 @@ cdata.set('HAVE_LIBSELINUX',
 ###############################################################
 
 systemd = not_found_dep
-systemdopt = get_option('systemd')
-if meson.version().version_compare('>=0.59')
-  systemdopt = systemdopt.disable_auto_if(host_system != 'linux')
+if host_system == 'linux'
+  systemd = dependency('libsystemd', required: get_option('systemd'))
+  cdata.set('USE_SYSTEMD', systemd.found() ? 1 : false)
 endif
-systemd = dependency('libsystemd', required: systemdopt)
-cdata.set('USE_SYSTEMD', systemd.found() ? 1 : false)
 
 
 
-- 
Tristan Partin
Neon (https://neon.tech)

