Fixed bug 3301 - IBus support on Linux with CMake
authorSam Lantinga <slouken@libsdl.org>
Sat, 01 Oct 2016 12:48:08 -0700
changeset 10419efb26f3918c4
parent 10418 ff5f3b3e6940
child 10420 0d91817f35e9
Fixed bug 3301 - IBus support on Linux with CMake


joe.gsoc16

I recently looked into Unicode support in SDL2 and realized that
SDL_TEXTEDITING doesn't get triggered at all (Japanese IME).
According to others on IRC it works fine on Windows/Mac but not
for me on (arch)Linux.
When compiling SDL with autotools, IBus support is enabled by
default but not so with CMake.
I never used CMake before but got it working and also included
that pkg-config determines flags for dbus (FIXME in CMakeLists).
CMakeLists.txt
include/SDL_config.h.cmake
     1.1 --- a/CMakeLists.txt	Sat Oct 01 12:46:36 2016 -0700
     1.2 +++ b/CMakeLists.txt	Sat Oct 01 12:48:08 2016 -0700
     1.3 @@ -899,8 +899,22 @@
     1.4  
     1.5      check_include_file("libudev.h" HAVE_LIBUDEV_H)
     1.6  
     1.7 -    # !!! FIXME: this needs pkg-config to find the include path, I think.
     1.8 -    check_include_file("dbus/dbus.h" HAVE_DBUS_DBUS_H)
     1.9 +    if(PKG_CONFIG_FOUND)
    1.10 +      pkg_search_module(DBUS dbus-1 dbus)
    1.11 +      if(DBUS_FOUND)
    1.12 +        set(HAVE_DBUS_DBUS_H TRUE)
    1.13 +        include_directories(${DBUS_INCLUDE_DIRS})
    1.14 +        list(APPEND EXTRA_LIBS ${DBUS_LIBRARIES})
    1.15 +      endif()
    1.16 +
    1.17 +      pkg_search_module(IBUS ibus-1.0 ibus)
    1.18 +      if(IBUS_FOUND)
    1.19 +        set(HAVE_IBUS_IBUS_H TRUE)
    1.20 +        include_directories(${IBUS_INCLUDE_DIRS})
    1.21 +        list(APPEND EXTRA_LIBS ${IBUS_LIBRARIES})
    1.22 +      endif()
    1.23 +    endif()
    1.24 +
    1.25    endif()
    1.26  
    1.27    if(INPUT_TSLIB)
     2.1 --- a/include/SDL_config.h.cmake	Sat Oct 01 12:46:36 2016 -0700
     2.2 +++ b/include/SDL_config.h.cmake	Sat Oct 01 12:48:08 2016 -0700
     2.3 @@ -81,6 +81,7 @@
     2.4  #cmakedefine HAVE_PTHREAD_NP_H 1
     2.5  #cmakedefine HAVE_LIBUDEV_H 1
     2.6  #cmakedefine HAVE_DBUS_DBUS_H 1
     2.7 +#cmakedefine HAVE_IBUS_IBUS_H 1
     2.8  
     2.9  /* C library functions */
    2.10  #cmakedefine HAVE_MALLOC 1