CMake project files no longer force you to link against Wayland or Mir libs.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 20 Mar 2015 10:35:42 -0400
changeset 94099df20f292907
parent 9408 93ba64cb5e16
child 9410 e25530faeda0
CMake project files no longer force you to link against Wayland or Mir libs.
CMakeLists.txt
cmake/sdlchecks.cmake
include/SDL_config.h.cmake
     1.1 --- a/CMakeLists.txt	Fri Mar 20 10:02:45 2015 -0400
     1.2 +++ b/CMakeLists.txt	Fri Mar 20 10:35:42 2015 -0400
     1.3 @@ -274,7 +274,10 @@
     1.4  set_option(INPUT_TSLIB         "Use the Touchscreen library for input" ${UNIX_SYS})
     1.5  set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
     1.6  set_option(VIDEO_WAYLAND       "Use Wayland video driver" ${UNIX_SYS})
     1.7 +dep_option(WAYLAND_SHARED      "Dynamically load Wayland support" ON "VIDEO_WAYLAND" OFF)
     1.8 +dep_option(VIDEO_WAYLAND_QT_TOUCH  "QtWayland server support for Wayland video driver" ON "VIDEO_WAYLAND" OFF)
     1.9  set_option(VIDEO_MIR           "Use Mir video driver" ${UNIX_SYS})
    1.10 +dep_option(MIR_SHARED          "Dynamically load Mir support" ON "VIDEO_MIR" OFF)
    1.11  set_option(VIDEO_RPI           "Use Raspberry Pi video driver" ${UNIX_SYS})
    1.12  dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
    1.13  set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
     2.1 --- a/cmake/sdlchecks.cmake	Fri Mar 20 10:02:45 2015 -0400
     2.2 +++ b/cmake/sdlchecks.cmake	Fri Mar 20 10:35:42 2015 -0400
     2.3 @@ -505,8 +505,13 @@
     2.4    endif()
     2.5  endmacro()
     2.6  
     2.7 +# Requires:
     2.8 +# - EGL
     2.9 +# - PkgCheckModules
    2.10 +# Optional:
    2.11 +# - MIR_SHARED opt
    2.12 +# - HAVE_DLOPEN opt
    2.13  macro(CheckMir)
    2.14 -# !!! FIXME: hook up dynamic loading here.
    2.15      if(VIDEO_MIR)
    2.16          find_library(MIR_LIB mirclient mircommon egl)
    2.17          pkg_check_modules(MIR_TOOLKIT mirclient mircommon)
    2.18 @@ -522,15 +527,31 @@
    2.19              set(SDL_VIDEO_DRIVER_MIR 1)
    2.20  
    2.21              list(APPEND EXTRA_CFLAGS ${MIR_TOOLKIT_CFLAGS} ${EGL_CLFAGS} ${XKB_CLFLAGS})
    2.22 -            list(APPEND EXTRA_LDFLAGS ${MIR_TOOLKIT_LDFLAGS} ${EGL_LDLAGS} ${XKB_LDLAGS})
    2.23 -        endif (MIR_LIB AND MIR_TOOLKIT_FOUND AND EGL_FOUND AND XKB_FOUND)
    2.24 +
    2.25 +            if(MIR_SHARED)
    2.26 +                if(NOT HAVE_DLOPEN)
    2.27 +                    message_warn("You must have SDL_LoadObject() support for dynamic Mir loading")
    2.28 +                else()
    2.29 +                    FindLibraryAndSONAME(mirclient)
    2.30 +                    FindLibraryAndSONAME(xkbcommon)
    2.31 +                    set(SDL_VIDEO_DRIVER_MIR_DYNAMIC "\"${MIRCLIENT_LIB_SONAME}\"")
    2.32 +                    set(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
    2.33 +                    set(HAVE_MIR_SHARED TRUE)
    2.34 +                endif()
    2.35 +            else()
    2.36 +                set(EXTRA_LIBS ${MIR_TOOLKIT_LIBRARIES} ${EXTRA_LIBS})
    2.37 +            endif()
    2.38 +        endif()
    2.39      endif()
    2.40  endmacro()
    2.41  
    2.42  # Requires:
    2.43  # - EGL
    2.44 +# - PkgCheckModules
    2.45 +# Optional:
    2.46 +# - WAYLAND_SHARED opt
    2.47 +# - HAVE_DLOPEN opt
    2.48  macro(CheckWayland)
    2.49 -# !!! FIXME: hook up dynamic loading here.
    2.50    if(VIDEO_WAYLAND)
    2.51      pkg_check_modules(WAYLAND wayland-client wayland-cursor wayland-egl egl xkbcommon)
    2.52      if(WAYLAND_FOUND)
    2.53 @@ -540,12 +561,34 @@
    2.54        include_directories(
    2.55            ${WAYLAND_INCLUDE_DIRS}
    2.56        )
    2.57 -      set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
    2.58        set(HAVE_VIDEO_WAYLAND TRUE)
    2.59        set(HAVE_SDL_VIDEO TRUE)
    2.60  
    2.61        file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
    2.62        set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
    2.63 +
    2.64 +      if(VIDEO_WAYLAND_QT_TOUCH)
    2.65 +          set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
    2.66 +      endif()
    2.67 +
    2.68 +      if(WAYLAND_SHARED)
    2.69 +        if(NOT HAVE_DLOPEN)
    2.70 +          message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
    2.71 +        else()
    2.72 +          FindLibraryAndSONAME(wayland-client)
    2.73 +          FindLibraryAndSONAME(wayland-egl)
    2.74 +          FindLibraryAndSONAME(wayland-cursor)
    2.75 +          FindLibraryAndSONAME(xkbcommon)
    2.76 +          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
    2.77 +          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
    2.78 +          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
    2.79 +          set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
    2.80 +          set(HAVE_WAYLAND_SHARED TRUE)
    2.81 +        endif()
    2.82 +      else()
    2.83 +        set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
    2.84 +      endif()
    2.85 +
    2.86        set(SDL_VIDEO_DRIVER_WAYLAND 1)
    2.87      endif()
    2.88    endif()
     3.1 --- a/include/SDL_config.h.cmake	Fri Mar 20 10:02:45 2015 -0400
     3.2 +++ b/include/SDL_config.h.cmake	Fri Mar 20 10:35:42 2015 -0400
     3.3 @@ -269,14 +269,11 @@
     3.4  #cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
     3.5  #cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
     3.6  
     3.7 -#if 0
     3.8 -/* !!! FIXME: in configure script version, missing here: */
     3.9 -#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    3.10 -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
    3.11 -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
    3.12 -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
    3.13 -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
    3.14 -#endif
    3.15 +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH@
    3.16 +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC@
    3.17 +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL@
    3.18 +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@
    3.19 +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@
    3.20  
    3.21  #cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@
    3.22  #cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@