meson.build: Check for libudev directly, instead of our flimsy os-speciffic guessing

Implement what was discussed in https://github.com/X11Libre/xserver/issues/478

Use dependency() instead of cc.check_header(), as the former is the
intended way to check for dependencies.

cc.check_headers would turn udev on on systems where libudev.h
is present, but libudev.pc isn't.

Thos would do the wrong thing on systems where the admin wants to
have that header for some reason, but doesn't want programs to use
libudev.

We also keep udev and udev_kms a tristate, so we try to do
the right thing when the user doesn't explicitly pass
values for udev and udev_kms.

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
stefan11111
2025-07-26 17:28:26 +03:00
committed by Enrico Weigelt
parent 879bc0012d
commit ed12dbbc18

View File

@@ -183,27 +183,13 @@ endif
udev_option = get_option('udev')
udev_kms_option = get_option('udev_kms')
if ['windows', 'darwin', 'netbsd', 'openbsd', 'sunos'].contains(host_machine.system())
if udev_option == 'auto'
udev_option = 'false'
endif
if udev_kms_option == 'auto'
udev_kms_option = 'false'
endif
if udev_option == 'true' or udev_kms_option == 'true'
message('WARNING: udev is not supported on your platform')
endif
else
if udev_option == 'auto'
udev_option = 'true'
endif
if udev_kms_option == 'auto'
udev_kms_option = 'true'
endif
if not dependency('libudev', required: (udev_option == 'true' or udev_kms_option == 'true')).found()
udev_option = 'false'
udev_kms_option = 'false'
endif
build_udev = (udev_option == 'true')
build_udev_kms = (udev_kms_option == 'true')
build_udev = (udev_option != 'false')
build_udev_kms = (udev_kms_option != 'false')
if get_option('systemd_logind') == 'auto'
build_systemd_logind = build_udev_kms and dbus_dep.found()