From d0e14008b5ce7ab0da440335df0eb3f7b8f85f31 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 25 Nov 2022 02:57:00 +0100 Subject: [PATCH] cmake: find libudev library so it gets priority --- CMakeLists.txt | 3 ++- cmake/sdlchecks.cmake | 13 +++++++++++++ include/SDL_config.h.cmake | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d772ce84d..b281ef8fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -508,6 +508,7 @@ set_option(SDL_HIDAPI "Enable the HIDAPI subsystem" ON) dep_option(SDL_HIDAPI_LIBUSB "Use libusb for low level joystick drivers" OFF SDL_HIDAPI OFF) dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" ON SDL_HIDAPI OFF) dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF) +set_option(SDL_LIBUDEV "Enable libudev support" ON) set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF) option_string(SDL_VENDOR_INFO "Vendor name and/or version to add to SDL_REVISION" "") set_option(SDL_CCACHE "Use Ccache to speed up build" ON) @@ -1495,7 +1496,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) set(SDL_INPUT_WSCONS 1) endif() - check_include_file("libudev.h" HAVE_LIBUDEV_H) + CheckLibUDev() check_include_file("sys/inotify.h" HAVE_SYS_INOTIFY_H) check_symbol_exists(inotify_init "sys/inotify.h" HAVE_INOTIFY_INIT) check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 80c904f5a..37d9a3889 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -1139,3 +1139,16 @@ macro(CheckKMSDRM) endif() endif() endmacro() + +macro(CheckLibUDev) + if(SDL_LIBUDEV) + check_include_file("libudev.h" have_libudev_header) + if(have_libudev_header) + set(HAVE_LIBUDEV_H TRUE) + FindLibraryAndSONAME(udev) + if(UDEV_LIB_SONAME) + set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"") + endif() + endif() + endif() +endmacro() diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index e16bb96ca..d24087e8d 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -345,6 +345,7 @@ #cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@ #cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@ #cmakedefine SDL_LIBUSB_DYNAMIC @SDL_LIBUSB_DYNAMIC@ +#cmakedefine SDL_UDEV_DYNAMIC @SDL_UDEV_DYNAMIC@ /* Enable various sensor drivers */ #cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@