From 6d7bceb41d6bd2e89f71c15784435728d78a6081 Mon Sep 17 00:00:00 2001
From: Brad Smith <[EMAIL REDACTED]>
Date: Sat, 17 Jan 2026 00:49:44 -0500
Subject: [PATCH] cmake: Fix header detection with CheckUSBHID
Make use of check_include_files to be able to also include
stdint.h when checking for the headers. Fixes detection of
usbhid.h on OpenBSD.
/usr/include/usbhid.h:40:2: error: unknown type name 'uint32_t'
40 | uint32_t _usage_page;
| ^
(cherry picked from commit 410a35fbee9c2211f6d824c2d65b44d22009212d)
---
CMakeLists.txt | 1 +
cmake/sdlchecks.cmake | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 365fcbb9baddb..2c6c02b2d0c8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,6 +46,7 @@ endif()
include(CheckLibraryExists)
include(CheckIncludeFile)
+include(CheckIncludeFiles)
include(CheckLanguage)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index 8c20082637f70..c96f6877083a7 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -946,22 +946,22 @@ macro(CheckUSBHID)
cmake_push_check_state()
check_library_exists(usbhid hid_init "" LIBUSBHID)
if(LIBUSBHID)
- check_include_file(usbhid.h HAVE_USBHID_H)
+ check_include_files("stdint.h;usbhid.h" HAVE_USBHID_H)
if(HAVE_USBHID_H)
set(USB_CFLAGS "-DHAVE_USBHID_H")
endif()
- check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
+ check_include_files("stdint.h;libusbhid.h" HAVE_LIBUSBHID_H)
if(HAVE_LIBUSBHID_H)
string(APPEND USB_CFLAGS " -DHAVE_LIBUSBHID_H")
endif()
set(USB_LIBS ${USB_LIBS} usbhid)
else()
- check_include_file(usb.h HAVE_USB_H)
+ check_include_files("stdint.h;usb.h" HAVE_USB_H)
if(HAVE_USB_H)
set(USB_CFLAGS "-DHAVE_USB_H")
endif()
- check_include_file(libusb.h HAVE_LIBUSB_H)
+ check_include_files("stdint.h;libusb.h" HAVE_LIBUSB_H)
if(HAVE_LIBUSB_H)
string(APPEND USB_CFLAGS " -DHAVE_LIBUSB_H")
endif()