From ded023870d40f909fb224fbaf42a6d3c1d96d7f6 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 16 May 2021 17:16:54 +0600 Subject: [PATCH] Make CMake script more accurate to autoconf script DBus, IBus and inotify is now able to be used outside Linux like in configure. KMSDRM input is now working on FreeBSD with CMake compilation. --- CMakeLists.txt | 51 ++++++++++++++++++++++++++++++-------- include/SDL_config.h.cmake | 1 + 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 358f32f3a..ec6b7a746 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1215,9 +1215,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) if(UNIX) file(GLOB CORE_UNIX_SOURCES ${SDL2_SOURCE_DIR}/src/core/unix/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${CORE_UNIX_SOURCES}) - endif() - if(LINUX) check_c_source_compiles(" #include #ifndef EVIOCGNAME @@ -1225,16 +1223,28 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) #endif int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS) - check_c_source_compiles(" - #include - #include + if(LINUX) + check_c_source_compiles(" + #include + #include - int main(int argc, char **argv) - { - struct kbentry kbe; - kbe.kb_table = KG_CTRL; - ioctl(0, KDGKBENT, &kbe); - }" HAVE_INPUT_KD) + int main(int argc, char **argv) + { + struct kbentry kbe; + kbe.kb_table = KG_CTRL; + ioctl(0, KDGKBENT, &kbe); + }" HAVE_INPUT_KD) + elseif(FREEBSD) + check_c_source_compiles(" + #include + #include + + int main(int argc, char **argv) + { + accentmap_t accTable; + ioctl(0, KDENABIO, 1); + }" HAVE_INPUT_KBIO) + endif() if(HAVE_INPUT_EVENTS) set(SDL_INPUT_LINUXEV 1) @@ -1250,11 +1260,16 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) if(HAVE_INPUT_KD) set(SDL_INPUT_LINUXKD 1) endif() + + if(HAVE_INPUT_KBIO) + set(SDL_INPUT_FBSDKBIO 1) + endif() check_include_file("libudev.h" HAVE_LIBUDEV_H) 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) + if(HAVE_SYS_INOTIFY_H AND HAVE_INOTIFY_INIT) set(HAVE_INOTIFY 1) endif() @@ -1280,6 +1295,16 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) set(SDL_USE_IME TRUE) add_definitions(-DSDL_USE_IME) # !!! FIXME: why isn't this a definition and not in SDL_config.h.cmake? endif() + + if(FREEBSD AND NOT HAVE_INOTIFY) + pkg_search_module(INOTIFY libinotify) + if(INOTIFY_FOUND) + set(HAVE_INOTIFY 1) + include_directories(${INOTIFY_INCLUDE_DIRS}) + list(APPEND EXTRA_LIBS ${INOTIFY_LIBRARIES}) + endif() + endif() + if(HAVE_LIBUNWIND_H) # We've already found the header, so REQUIRE the lib to be present pkg_search_module(UNWIND REQUIRED libunwind) @@ -1312,6 +1337,10 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) set(SOURCE_FILES ${SOURCE_FILES} "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev.c") set(SOURCE_FILES ${SOURCE_FILES} "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev_kbd.c") endif() + + if(HAVE_INPUT_KBIO) + set(SOURCE_FILES ${SOURCE_FILES} "${SDL2_SOURCE_DIR}/src/core/freebsd/SDL_evdev_kbd_freebsd.c") + endif() # Always compiled for Linux, unconditionally: set(SOURCE_FILES ${SOURCE_FILES} "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev_capabilities.c") diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 0446547e0..8463f47b1 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -302,6 +302,7 @@ /* Enable various input drivers */ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ #cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@ +#cmakedefine SDL_INPUT_FBSDKBIO @SDL_INPUT_FBSDKBIO@ #cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@ #cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@ #cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@