SDL: cmake: check linkage to libusb too, instead of libusb.h presence only.

From f617918e0a5c5048ce1fc71c6e3f05be3310bcca Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 26 Aug 2023 15:55:50 +0300
Subject: [PATCH] cmake: check linkage to libusb too, instead of libusb.h
 presence only.

avoids false positives when using a cross-toolchain file
---
 cmake/sdlchecks.cmake | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index bf656cc491ee..478c5691452d 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -1029,7 +1029,14 @@ macro(CheckHIDAPI)
       if(PC_LIBUSB_FOUND)
         cmake_push_check_state()
         list(APPEND CMAKE_REQUIRED_INCLUDES ${PC_LIBUSB_INCLUDE_DIRS})
-        check_include_file(libusb.h HAVE_LIBUSB_H)
+        list(APPEND CMAKE_REQUIRED_LIBRARIES PkgConfig::PC_LIBUSB)
+        check_c_source_compiles("
+          #include <stddef.h>
+          #include <libusb.h>
+          int main(int argc, char **argv) {
+            libusb_close(NULL);
+            return 0;
+          }" HAVE_LIBUSB_H)
         cmake_pop_check_state()
         if(HAVE_LIBUSB_H)
           set(HAVE_LIBUSB TRUE)