SDL: cmake: add SDL_IBUS option to enable/disable DBUS + test sys/inotify.h

From 32c4996c04a7214a85cce2476547a5532ff95faf Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 26 Aug 2022 02:38:54 +0200
Subject: [PATCH] cmake: add SDL_IBUS option to enable/disable DBUS + test
 sys/inotify.h

---
 CMakeLists.txt | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c29143a484..c7541b34396 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -446,6 +446,7 @@ set_option(SDL_DUMMYAUDIO          "Support the dummy audio driver" ON)
 set_option(SDL_DIRECTFB            "Use DirectFB video driver" OFF)
 dep_option(SDL_DIRECTFB_SHARED     "Dynamically load directfb support" ON "SDL_DIRECTFB" OFF)
 set_option(SDL_DUMMYVIDEO          "Use dummy video driver" ON)
+dep_option(SDL_IBUS                "Enable IBus support" ON ${UNIX_SYS} OFF)
 set_option(SDL_OPENGL              "Include OpenGL support" ON)
 set_option(SDL_OPENGLES            "Include OpenGL ES support" ON)
 set_option(SDL_PTHREADS            "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
@@ -1443,10 +1444,14 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
         endif()
       endif()
 
-      pkg_search_module(IBUS ibus-1.0 ibus)
-      if(IBUS_FOUND)
-        set(HAVE_IBUS_IBUS_H TRUE)
-        target_include_directories(sdl-build-options INTERFACE "${IBUS_INCLUDE_DIRS}")
+      if(SDL_IBUS)
+        pkg_search_module(IBUS ibus-1.0 ibus)
+        find_path(HAVE_SYS_INOTIFY_H NAMES sys/inotify.h)
+        if(IBUS_FOUND AND HAVE_SYS_INOTIFY_H)
+          set(HAVE_IBUS_IBUS_H TRUE)
+          target_include_directories(sdl-build-options INTERFACE "${IBUS_INCLUDE_DIRS}")
+          set(HAVE_IBUS TRUE)
+        endif()
       endif()
 
       if (HAVE_IBUS_IBUS_H OR HAVE_FCITX)