cmake/sdlchecks.cmake
author Ryan C. Gordon <icculus@icculus.org>
Tue, 21 Jan 2014 16:28:53 -0500
changeset 8120 c858be546e5a
parent 8062 4fc5f66d63cc
child 8153 3e43c73ac79b
permissions -rw-r--r--
Fixed XF86 VidMode extension dynamic loading with CMake project.
     1 macro(FindLibraryAndSONAME _LIB)
     2   string(TOUPPER ${_LIB} _UPPERLNAME)
     3   string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
     4 
     5   find_library(${_LNAME}_LIB ${_LIB})
     6   if(${_LNAME}_LIB)
     7     # reduce the library name for shared linking
     8 
     9     get_filename_component(_LIB_REALPATH ${${_LNAME}_LIB} REALPATH)  # resolves symlinks
    10     get_filename_component(_LIB_JUSTNAME ${_LIB_REALPATH} NAME)
    11 
    12     if(APPLE)
    13       string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*dylib$" "\\1.dylib" _LIB_REGEXD "${_LIB_JUSTNAME}")
    14     else()
    15       string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*$" "\\1" _LIB_REGEXD "${_LIB_JUSTNAME}")
    16     endif()
    17 
    18     SET(_DEBUG_FindSONAME FALSE)
    19     if(_DEBUG_FindSONAME)
    20       message_warn("DYNLIB OUTPUTVAR: ${_LIB} ... ${_LNAME}_LIB")
    21       message_warn("DYNLIB ORIGINAL LIB: ${_LIB} ... ${${_LNAME}_LIB}")
    22       message_warn("DYNLIB REALPATH LIB: ${_LIB} ... ${_LIB_REALPATH}")
    23       message_warn("DYNLIB JUSTNAME LIB: ${_LIB} ... ${_LIB_JUSTNAME}")
    24       message_warn("DYNLIB REGEX'd LIB: ${_LIB} ... ${_LIB_REGEXD}")
    25     endif()
    26 
    27     message(STATUS "dynamic lib${_LIB} -> ${_LIB_REGEXD}")
    28     set(${_LNAME}_LIB_SONAME ${_LIB_REGEXD})
    29   endif()
    30 endmacro()
    31 
    32 macro(CheckDLOPEN)
    33   check_function_exists(dlopen HAVE_DLOPEN)
    34   if(NOT HAVE_DLOPEN)
    35     foreach(_LIBNAME dl tdl)
    36       check_library_exists("${_LIBNAME}" "dlopen" "" DLOPEN_LIB)
    37       if(DLOPEN_LIB)
    38         list(APPEND EXTRA_LIBS ${_LIBNAME})
    39         set(_DLLIB ${_LIBNAME})
    40         set(HAVE_DLOPEN TRUE)
    41         break()
    42       endif(DLOPEN_LIB)
    43     endforeach()
    44   endif()
    45 
    46   if(HAVE_DLOPEN)
    47     if(_DLLIB)
    48       set(CMAKE_REQUIRED_LIBRARIES ${_DLLIB})
    49     endif()
    50     check_c_source_compiles("
    51        #include <dlfcn.h>
    52        int main(int argc, char **argv) {
    53          void *handle = dlopen(\"\", RTLD_NOW);
    54          const char *loaderror = (char *) dlerror();
    55        }" HAVE_DLOPEN)
    56     set(CMAKE_REQUIRED_LIBRARIES)
    57   endif()
    58 
    59   if (HAVE_DLOPEN)
    60     set(SDL_LOADSO_DLOPEN 1)
    61     set(HAVE_SDL_DLOPEN TRUE)
    62     file(GLOB DLOPEN_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
    63     set(SOURCE_FILES ${SOURCE_FILES} ${DLOPEN_SOURCES})
    64     set(HAVE_SDL_LOADSO TRUE)
    65   endif()
    66 endmacro(CheckDLOPEN)
    67 
    68 # Requires:
    69 # - n/a
    70 macro(CheckOSS)
    71   if(OSS)
    72     set(OSS_HEADER_FILE "sys/soundcard.h")
    73     check_c_source_compiles("
    74         #include <sys/soundcard.h>
    75         int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
    76     if(NOT OSS_FOUND)
    77       set(OSS_HEADER_FILE "soundcard.h")
    78       check_c_source_compiles("
    79           #include <soundcard.h>
    80           int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
    81     endif(NOT OSS_FOUND)
    82 
    83     if(OSS_FOUND)
    84       set(HAVE_OSS TRUE)
    85       file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
    86       if(OSS_HEADER_FILE STREQUAL "soundcard.h")
    87         set(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H 1)
    88       endif(OSS_HEADER_FILE STREQUAL "soundcard.h")
    89       set(SDL_AUDIO_DRIVER_OSS 1)
    90       set(SOURCE_FILES ${SOURCE_FILES} ${OSS_SOURCES})
    91       if(NETBSD OR OPENBSD)
    92         list(APPEND EXTRA_LIBS ossaudio)
    93       endif(NETBSD OR OPENBSD)
    94       set(HAVE_SDL_AUDIO TRUE)
    95     endif(OSS_FOUND)
    96   endif(OSS)
    97 endmacro(CheckOSS)
    98 
    99 # Requires:
   100 # - n/a
   101 # Optional:
   102 # - ALSA_SHARED opt
   103 # - HAVE_DLOPEN opt
   104 macro(CheckALSA)
   105   if(ALSA)
   106     CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
   107     if(HAVE_ASOUNDLIB_H)
   108       CHECK_LIBRARY_EXISTS(asound snd_pcm_open "" HAVE_LIBASOUND)
   109       set(HAVE_ALSA TRUE)
   110       file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
   111       set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
   112       set(SDL_AUDIO_DRIVER_ALSA 1)
   113       if(ALSA_SHARED)
   114         if(NOT HAVE_DLOPEN)
   115           message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
   116         else()
   117           FindLibraryAndSONAME("asound")
   118           set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
   119           set(HAVE_ALSA_SHARED TRUE)
   120         endif(NOT HAVE_DLOPEN)
   121       else(ALSA_SHARED)
   122         list(APPEND EXTRA_LIBS asound)
   123       endif(ALSA_SHARED)
   124       set(HAVE_SDL_AUDIO TRUE)
   125     endif(HAVE_ASOUNDLIB_H)
   126   endif(ALSA)
   127 endmacro(CheckALSA)
   128 
   129 # Requires:
   130 # - PkgCheckModules
   131 # Optional:
   132 # - PULSEAUDIO_SHARED opt
   133 # - HAVE_DLOPEN opt
   134 macro(CheckPulseAudio)
   135   if(PULSEAUDIO)
   136     pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
   137     if(PKG_PULSEAUDIO_FOUND)
   138       set(HAVE_PULSEAUDIO TRUE)
   139       file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c)
   140       set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
   141       set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
   142       list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
   143       if(PULSEAUDIO_SHARED)
   144         if(NOT HAVE_DLOPEN)
   145           message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
   146         else()
   147           FindLibraryAndSONAME("pulse-simple")
   148           set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
   149           set(HAVE_PULSEAUDIO_SHARED TRUE)
   150         endif(NOT HAVE_DLOPEN)
   151       else(PULSEAUDIO_SHARED)
   152         list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
   153       endif(PULSEAUDIO_SHARED)
   154       set(HAVE_SDL_AUDIO TRUE)
   155     endif(PKG_PULSEAUDIO_FOUND)
   156   endif(PULSEAUDIO)
   157 endmacro(CheckPulseAudio)
   158 
   159 # Requires:
   160 # - PkgCheckModules
   161 # Optional:
   162 # - ESD_SHARED opt
   163 # - HAVE_DLOPEN opt
   164 macro(CheckESD)
   165   if(ESD)
   166     pkg_check_modules(PKG_ESD esound)
   167     if(PKG_ESD_FOUND)
   168       set(HAVE_ESD TRUE)
   169       file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c)
   170       set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
   171       set(SDL_AUDIO_DRIVER_ESD 1)
   172       list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
   173       if(ESD_SHARED)
   174         if(NOT HAVE_DLOPEN)
   175           message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
   176         else()
   177           FindLibraryAndSONAME(esd)
   178           set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
   179           set(HAVE_ESD_SHARED TRUE)
   180         endif(NOT HAVE_DLOPEN)
   181       else(ESD_SHARED)
   182         list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
   183       endif(ESD_SHARED)
   184       set(HAVE_SDL_AUDIO TRUE)
   185     endif(PKG_ESD_FOUND)
   186   endif(ESD)
   187 endmacro(CheckESD)
   188 
   189 # Requires:
   190 # - n/a
   191 # Optional:
   192 # - ARTS_SHARED opt
   193 # - HAVE_DLOPEN opt
   194 macro(CheckARTS)
   195   if(ARTS)
   196     find_program(ARTS_CONFIG arts-config)
   197     if(ARTS_CONFIG)
   198       execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
   199         OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
   200       list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS})
   201       execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs
   202         OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
   203       file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c)
   204       set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
   205       set(SDL_AUDIO_DRIVER_ARTS 1)
   206       set(HAVE_ARTS TRUE)
   207       if(ARTS_SHARED)
   208         if(NOT HAVE_DLOPEN)
   209           message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
   210         else()
   211           # TODO
   212           FindLibraryAndSONAME(artsc)
   213           set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
   214           set(HAVE_ARTS_SHARED TRUE)
   215         endif(NOT HAVE_DLOPEN)
   216       else(ARTS_SHARED)
   217         list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
   218       endif(ARTS_SHARED)
   219       set(HAVE_SDL_AUDIO TRUE)
   220     endif(ARTS_CONFIG)
   221   endif(ARTS)
   222 endmacro(CheckARTS)
   223 
   224 # Requires:
   225 # - n/a
   226 # Optional:
   227 # - NAS_SHARED opt
   228 # - HAVE_DLOPEN opt
   229 macro(CheckNAS)
   230   if(NAS)
   231     # TODO: set include paths properly, so the NAS headers are found
   232     check_include_file(audio/audiolib.h HAVE_NAS_H)
   233     find_library(D_NAS_LIB audio)
   234     if(HAVE_NAS_H AND D_NAS_LIB)
   235       set(HAVE_NAS TRUE)
   236       file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
   237       set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
   238       set(SDL_AUDIO_DRIVER_NAS 1)
   239       if(NAS_SHARED)
   240         if(NOT HAVE_DLOPEN)
   241           message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
   242         else()
   243           FindLibraryAndSONAME("audio")
   244           set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
   245           set(HAVE_NAS_SHARED TRUE)
   246         endif(NOT HAVE_DLOPEN)
   247       else(NAS_SHARED)
   248         list(APPEND EXTRA_LIBS ${D_NAS_LIB})
   249       endif(NAS_SHARED)
   250       set(HAVE_SDL_AUDIO TRUE)
   251     endif(HAVE_NAS_H AND D_NAS_LIB)
   252   endif(NAS)
   253 endmacro(CheckNAS)
   254 
   255 # Requires:
   256 # - n/a
   257 # Optional:
   258 # - SNDIO_SHARED opt
   259 # - HAVE_DLOPEN opt
   260 macro(CheckSNDIO)
   261   if(SNDIO)
   262     # TODO: set include paths properly, so the sndio headers are found
   263     check_include_file(sndio.h HAVE_SNDIO_H)
   264     find_library(D_SNDIO_LIB sndio)
   265     if(HAVE_SNDIO_H AND D_SNDIO_LIB)
   266       set(HAVE_SNDIO TRUE)
   267       file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
   268       set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
   269       set(SDL_AUDIO_DRIVER_SNDIO 1)
   270       if(SNDIO_SHARED)
   271         if(NOT HAVE_DLOPEN)
   272           message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
   273         else()
   274           FindLibraryAndSONAME("sndio")
   275           set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
   276           set(HAVE_SNDIO_SHARED TRUE)
   277         endif(NOT HAVE_DLOPEN)
   278       else(SNDIO_SHARED)
   279         list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
   280       endif(SNDIO_SHARED)
   281       set(HAVE_SDL_AUDIO TRUE)
   282     endif(HAVE_SNDIO_H AND D_SNDIO_LIB)
   283   endif(SNDIO)
   284 endmacro(CheckSNDIO)
   285 
   286 # Requires:
   287 # - PkgCheckModules
   288 # Optional:
   289 # - FUSIONSOUND_SHARED opt
   290 # - HAVE_DLOPEN opt
   291 macro(CheckFusionSound)
   292   if(FUSIONSOUND)
   293     pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0)
   294     if(PKG_FUSIONSOUND_FOUND)
   295       set(HAVE_FUSIONSOUND TRUE)
   296       file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c)
   297       set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
   298       set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
   299       list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
   300       if(FUSIONSOUND_SHARED)
   301         if(NOT HAVE_DLOPEN)
   302           message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
   303         else()
   304           FindLibraryAndSONAME("fusionsound")
   305           set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
   306           set(HAVE_FUSIONSOUND_SHARED TRUE)
   307         endif(NOT HAVE_DLOPEN)
   308       else(FUSIONSOUND_SHARED)
   309         list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
   310       endif(FUSIONSOUND_SHARED)
   311       set(HAVE_SDL_AUDIO TRUE)
   312     endif(PKG_FUSIONSOUND_FOUND)
   313   endif(FUSIONSOUND)
   314 endmacro(CheckFusionSound)
   315 
   316 # Requires:
   317 # - n/a
   318 # Optional:
   319 # - X11_SHARED opt
   320 # - HAVE_DLOPEN opt
   321 macro(CheckX11)
   322   if(VIDEO_X11)
   323     foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
   324         FindLibraryAndSONAME("${_LIB}")
   325     endforeach()
   326 
   327     find_path(X_INCLUDEDIR X11/Xlib.h)
   328     if(X_INCLUDEDIR)
   329       set(X_CFLAGS "-I${X_INCLUDEDIR}")
   330     endif()
   331 
   332     check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
   333     check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
   334     check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H)
   335     check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
   336     check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
   337     check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
   338     check_include_file(X11/extensions/shape.h HAVE_XSHAPE_H)
   339     check_include_files("X11/Xlib.h;X11/extensions/xf86vmode.h" HAVE_XF86VM_H)
   340     check_include_files("X11/Xlib.h;X11/Xproto.h;X11/extensions/Xext.h" HAVE_XEXT_H)
   341 
   342     if(X11_LIB)
   343       if(NOT HAVE_XEXT_H)
   344         message_error("Missing Xext.h, maybe you need to install the libxext-dev package?")
   345       endif()
   346 
   347       set(HAVE_VIDEO_X11 TRUE)
   348       set(HAVE_SDL_VIDEO TRUE)
   349 
   350       file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
   351       set(SOURCE_FILES ${SOURCE_FILES} ${X11_SOURCES})
   352       set(SDL_VIDEO_DRIVER_X11 1)
   353 
   354       if(APPLE)
   355         set(X11_SHARED OFF)
   356       endif(APPLE)
   357 
   358       check_function_exists("shmat" HAVE_SHMAT)
   359       if(NOT HAVE_SHMAT)
   360         check_library_exists(ipc shmat "" HAVE_SHMAT)
   361         if(HAVE_SHMAT)
   362           list(APPEND EXTRA_LIBS ipc)
   363         endif(HAVE_SHMAT)
   364         if(NOT HAVE_SHMAT)
   365           add_definitions(-DNO_SHARED_MEMORY)
   366           set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY")
   367         endif(NOT HAVE_SHMAT)
   368       endif(NOT HAVE_SHMAT)
   369 
   370       if(X11_SHARED)
   371         if(NOT HAVE_DLOPEN)
   372           message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
   373           set(HAVE_X11_SHARED FALSE)
   374         else(NOT HAVE_DLOPEN)
   375           set(HAVE_X11_SHARED TRUE)
   376         endif()
   377         if(HAVE_X11_SHARED)
   378           set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
   379           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
   380         else(HAVE_X11_SHARED)
   381           list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
   382         endif(HAVE_X11_SHARED)
   383       endif(X11_SHARED)
   384 
   385       set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}")
   386 
   387       set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
   388       check_c_source_compiles("
   389           #include <X11/Xlib.h>
   390           #include <X11/Xproto.h>
   391           #include <X11/extensions/Xext.h>
   392           #include <X11/extensions/extutil.h>
   393           extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
   394           int main(int argc, char **argv) {}" HAVE_CONST_XEXT_ADDDISPLAY)
   395       if(HAVE_CONST_XEXT_ADDDISPLAY)
   396         set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1)
   397       endif(HAVE_CONST_XEXT_ADDDISPLAY)
   398 
   399       check_c_source_compiles("
   400           #include <X11/Xlib.h>
   401           int main(int argc, char **argv) {
   402             Display *display;
   403             XEvent event;
   404             XGenericEventCookie *cookie = &event.xcookie;
   405             XNextEvent(display, &event);
   406             XGetEventData(display, cookie);
   407             XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
   408       if(HAVE_XGENERICEVENT)
   409         set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
   410       endif(HAVE_XGENERICEVENT)
   411 
   412       check_c_source_compiles("
   413           #include <X11/Xlibint.h>
   414           extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
   415           int main(int argc, char **argv) {}" HAVE_CONST_XDATA32)
   416       if(HAVE_CONST_XDATA32)
   417         set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1)
   418       endif(HAVE_CONST_XDATA32)
   419 
   420       check_function_exists(XkbKeycodeToKeysym SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
   421 
   422       if(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
   423         set(HAVE_VIDEO_X11_XCURSOR TRUE)
   424         if(HAVE_X11_SHARED AND XCURSOR_LIB)
   425           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
   426         else(HAVE_X11_SHARED AND XCURSOR_LIB)
   427           list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
   428         endif(HAVE_X11_SHARED AND XCURSOR_LIB)
   429         set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
   430       endif(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
   431 
   432       if(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
   433         set(HAVE_VIDEO_X11_XINERAMA TRUE)
   434         if(HAVE_X11_SHARED AND XINERAMA_LIB)
   435           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB_SONAME}\"")
   436         else(HAVE_X11_SHARED AND XINERAMA_LIB)
   437           list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
   438         endif(HAVE_X11_SHARED AND XINERAMA_LIB)
   439         set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
   440       endif(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
   441 
   442       if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
   443         set(HAVE_VIDEO_X11_XINPUT TRUE)
   444         if(HAVE_X11_SHARED AND XI_LIB)
   445           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
   446         else(HAVE_X11_SHARED AND XI_LIB)
   447           list(APPEND EXTRA_LIBS ${XI_LIB})
   448         endif(HAVE_X11_SHARED AND XI_LIB)
   449         set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
   450 
   451         # Check for multitouch
   452         check_c_source_compiles("
   453             #include <X11/Xlib.h>
   454             #include <X11/Xproto.h>
   455             #include <X11/extensions/XInput2.h>
   456             int event_type = XI_TouchBegin;
   457             XITouchClassInfo *t;
   458             Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
   459             {
   460               return (Status)0;
   461             }
   462             int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
   463         if(HAVE_XINPUT2_MULTITOUCH)
   464           set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
   465         endif(HAVE_XINPUT2_MULTITOUCH)
   466       endif(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
   467 
   468       if(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
   469         if(HAVE_X11_SHARED AND XRANDR_LIB)
   470           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
   471         else(HAVE_X11_SHARED AND XRANDR_LIB)
   472           list(APPEND EXTRA_LIBS ${XRANDR_LIB})
   473         endif(HAVE_X11_SHARED AND XRANDR_LIB)
   474         set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
   475         set(HAVE_VIDEO_X11_XRANDR TRUE)
   476       endif(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
   477 
   478       if(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
   479         if(HAVE_X11_SHARED AND XSS_LIB)
   480           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
   481         else(HAVE_X11_SHARED AND XSS_LIB)
   482           list(APPEND EXTRA_LIBS ${XSS_LIB})
   483         endif(HAVE_X11_SHARED AND XSS_LIB)
   484         set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
   485         set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
   486       endif(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
   487 
   488       if(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
   489         set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
   490         set(HAVE_VIDEO_X11_XSHAPE TRUE)
   491       endif(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
   492 
   493       if(VIDEO_X11_XVM AND HAVE_XF86VM_H)
   494         if(HAVE_X11_SHARED AND XXF86VM_LIB)
   495           set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XXF86VM_LIB_SONAME}\"")
   496         else(HAVE_X11_SHARED AND XXF86VM_LIB)
   497           list(APPEND EXTRA_LIBS ${XXF86VM_LIB})
   498         endif(HAVE_X11_SHARED AND XXF86VM_LIB)
   499         set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
   500         set(HAVE_VIDEO_X11_XVM TRUE)
   501       endif(VIDEO_X11_XVM AND HAVE_XF86VM_H)
   502 
   503       set(CMAKE_REQUIRED_LIBRARIES)
   504     endif(X11_LIB)
   505   endif(VIDEO_X11)
   506 endmacro(CheckX11)
   507 
   508 # Requires:
   509 # - EGL
   510 macro(CheckWayland)
   511   if(VIDEO_WAYLAND)
   512     pkg_check_modules(WAYLAND wayland-client wayland-cursor wayland-egl egl xkbcommon)
   513     if(WAYLAND_FOUND)
   514       link_directories(
   515           ${WAYLAND_LIBRARY_DIRS}
   516       )
   517       include_directories(
   518           ${WAYLAND_INCLUDE_DIRS}
   519       )
   520       set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
   521       set(HAVE_VIDEO_WAYLAND TRUE)
   522       set(HAVE_SDL_VIDEO TRUE)
   523 
   524       file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
   525       set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
   526       set(SDL_VIDEO_DRIVER_WAYLAND 1)
   527     endif(WAYLAND_FOUND)
   528   endif(VIDEO_WAYLAND)
   529 endmacro(CheckWayland)
   530 
   531 # Requires:
   532 # - n/a
   533 #
   534 macro(CheckCOCOA)
   535   if(VIDEO_COCOA)
   536     check_objc_source_compiles("
   537         #import <Cocoa/Cocoa.h>
   538         int main (int argc, char** argv) {}" HAVE_VIDEO_COCOA)
   539     if(HAVE_VIDEO_COCOA)
   540       file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
   541       set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
   542       set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
   543       set(SDL_VIDEO_DRIVER_COCOA 1)
   544       set(HAVE_SDL_VIDEO TRUE)
   545     endif(HAVE_VIDEO_COCOA)
   546   endif(VIDEO_COCOA)
   547 endmacro(CheckCOCOA)
   548 
   549 # Requires:
   550 # - PkgCheckModules
   551 # Optional:
   552 # - DIRECTFB_SHARED opt
   553 # - HAVE_DLOPEN opt
   554 macro(CheckDirectFB)
   555   if(VIDEO_DIRECTFB)
   556     pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
   557     if(PKG_DIRECTFB_FOUND)
   558       set(HAVE_VIDEO_DIRECTFB TRUE)
   559       file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
   560       set(SOURCE_FILES ${SOURCE_FILES} ${DIRECTFB_SOURCES})
   561       set(SDL_VIDEO_DRIVER_DIRECTFB 1)
   562       set(SDL_VIDEO_RENDER_DIRECTFB 1)
   563       list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
   564       if(DIRECTFB_SHARED)
   565         if(NOT HAVE_DLOPEN)
   566           message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
   567         else()
   568           FindLibraryAndSONAME("directfb")
   569           set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
   570           set(HAVE_DIRECTFB_SHARED TRUE)
   571         endif(NOT HAVE_DLOPEN)
   572       else(DIRECTFB_SHARED)
   573         list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
   574       endif(DIRECTFB_SHARED)
   575       set(HAVE_SDL_VIDEO TRUE)
   576     endif(PKG_DIRECTFB_FOUND)
   577   endif(VIDEO_DIRECTFB)
   578 endmacro(CheckDirectFB)
   579 
   580 # Requires:
   581 # - nada
   582 macro(CheckOpenGLX11)
   583   if(VIDEO_OPENGL)
   584     check_c_source_compiles("
   585         #include <GL/gl.h>
   586         #include <GL/glx.h>
   587         int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL)
   588 
   589     if(HAVE_VIDEO_OPENGL)
   590       set(HAVE_VIDEO_OPENGL TRUE)
   591       set(SDL_VIDEO_OPENGL 1)
   592       set(SDL_VIDEO_OPENGL_GLX 1)
   593       set(SDL_VIDEO_RENDER_OGL 1)
   594       list(APPEND EXTRA_LIBS GL)
   595     endif(HAVE_VIDEO_OPENGL)
   596   endif(VIDEO_OPENGL)
   597 endmacro(CheckOpenGLX11)
   598 
   599 # Requires:
   600 # - nada
   601 macro(CheckOpenGLESX11)
   602   if(VIDEO_OPENGLES)
   603     check_c_source_compiles("
   604         #include <EGL/egl.h>
   605         int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL)
   606     if(HAVE_VIDEO_OPENGL_EGL)
   607         set(SDL_VIDEO_OPENGL_EGL 1)
   608     endif(HAVE_VIDEO_OPENGL_EGL) 
   609     check_c_source_compiles("
   610       #include <GLES/gl.h>
   611       #include <GLES/glext.h>
   612       int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1)
   613     if(HAVE_VIDEO_OPENGLES_V1)
   614         set(HAVE_VIDEO_OPENGLES TRUE)
   615         set(SDL_VIDEO_OPENGL_ES 1)
   616         set(SDL_VIDEO_RENDER_OGL_ES 1)
   617     endif(HAVE_VIDEO_OPENGLES_V1)
   618     check_c_source_compiles("
   619       #include <GLES2/gl2.h>
   620       #include <GLES2/gl2ext.h>
   621       int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2)
   622     if(HAVE_VIDEO_OPENGLES_V2)
   623         set(HAVE_VIDEO_OPENGLES TRUE)
   624         set(SDL_VIDEO_OPENGL_ES2 1)
   625         set(SDL_VIDEO_RENDER_OGL_ES2 1)
   626     endif(HAVE_VIDEO_OPENGLES_V2)
   627 
   628   endif(VIDEO_OPENGLES)
   629 endmacro(CheckOpenGLESX11)
   630 
   631 # Rquires:
   632 # - nada
   633 # Optional:
   634 # - THREADS opt
   635 # Sets:
   636 # PTHREAD_CFLAGS
   637 # PTHREAD_LIBS
   638 macro(CheckPTHREAD)
   639   if(PTHREADS)
   640     if(LINUX)
   641       set(PTHREAD_CFLAGS "-D_REENTRANT")
   642       set(PTHREAD_LDFLAGS "-pthread")
   643     elseif(BSDI)
   644       set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   645       set(PTHREAD_LDFLAGS "")
   646     elseif(DARWIN)
   647       set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
   648       # causes Carbon.p complaints?
   649       # set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   650       set(PTHREAD_LDFLAGS "")
   651     elseif(FREEBSD)
   652       set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   653       set(PTHREAD_LDFLAGS "-pthread")
   654     elseif(NETBSD)
   655       set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   656       set(PTHREAD_LDFLAGS "-lpthread")
   657     elseif(OPENBSD)
   658       set(PTHREAD_CFLAGS "-D_REENTRANT")
   659       set(PTHREAD_LDFLAGS "-pthread")
   660     elseif(SOLARIS)
   661       set(PTHREAD_CFLAGS "-D_REENTRANT")
   662       set(PTHREAD_LDFLAGS "-pthread -lposix4")
   663     elseif(SYSV5)
   664       set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
   665       set(PTHREAD_LDFLAGS "")
   666     elseif(AIX)
   667       set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads")
   668       set(PTHREAD_LDFLAGS "-pthread")
   669     elseif(HPUX)
   670       set(PTHREAD_CFLAGS "-D_REENTRANT")
   671       set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
   672     elseif(HAIKU)
   673       set(PTHREAD_CFLAGS "-D_REENTRANT")
   674       set(PTHREAD_LDFLAGS "")
   675     else()
   676       set(PTHREAD_CFLAGS "-D_REENTRANT")
   677       set(PTHREAD_LDFLAGS "-lpthread")
   678     endif(LINUX)
   679 
   680     # Run some tests
   681     set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
   682     check_c_source_runs("
   683         #include <pthread.h>
   684         int main(int argc, char** argv) {
   685           pthread_attr_t type;
   686           pthread_attr_init(&type);
   687           return 0;
   688         }" HAVE_PTHREADS)
   689     if(HAVE_PTHREADS)
   690       set(SDL_THREAD_PTHREAD 1)
   691       list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
   692       list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
   693       set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
   694       list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS})
   695 
   696       check_c_source_compiles("
   697         #include <pthread.h>
   698         int main(int argc, char **argv) {
   699           pthread_mutexattr_t attr;
   700           pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
   701           return 0;
   702         }" HAVE_RECURSIVE_MUTEXES)
   703       if(HAVE_RECURSIVE_MUTEXES)
   704         set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
   705       else(HAVE_RECURSIVE_MUTEXES)
   706         check_c_source_compiles("
   707             #include <pthread.h>
   708             int main(int argc, char **argv) {
   709               pthread_mutexattr_t attr;
   710               pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
   711               return 0;
   712             }" HAVE_RECURSIVE_MUTEXES_NP)
   713         if(HAVE_RECURSIVE_MUTEXES_NP)
   714           set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
   715         endif(HAVE_RECURSIVE_MUTEXES_NP)
   716       endif(HAVE_RECURSIVE_MUTEXES)
   717 
   718       if(PTHREADS_SEM)
   719         check_c_source_compiles("#include <pthread.h>
   720                                  #include <semaphore.h>
   721                                  int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM)
   722         if(HAVE_PTHREADS_SEM)
   723           check_c_source_compiles("
   724               #include <pthread.h>
   725               #include <semaphore.h>
   726               int main(int argc, char **argv) {
   727                   sem_timedwait(NULL, NULL);
   728                   return 0;
   729               }" HAVE_SEM_TIMEDWAIT)
   730         endif(HAVE_PTHREADS_SEM)
   731       endif(PTHREADS_SEM)
   732 
   733       check_c_source_compiles("
   734           #include <pthread.h>
   735           int main(int argc, char** argv) {
   736               pthread_spin_trylock(NULL);
   737               return 0;
   738           }" HAVE_PTHREAD_SPINLOCK)
   739 
   740       check_c_source_compiles("
   741           #include <pthread.h>
   742           #include <pthread_np.h>
   743           int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
   744       check_function_exists(pthread_setname_np HAVE_PTHREAD_setNAME_NP)
   745       check_function_exists(pthread_set_name_np HAVE_PTHREAD_set_NAME_NP)
   746       set(CMAKE_REQUIRED_FLAGS)
   747 
   748       set(SOURCE_FILES ${SOURCE_FILES}
   749           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
   750           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c   # Can be faked, if necessary
   751           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c    # Can be faked, if necessary
   752           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systls.c
   753           )
   754       if(HAVE_PTHREADS_SEM)
   755         set(SOURCE_FILES ${SOURCE_FILES}
   756             ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
   757       else(HAVE_PTHREADS_SEM)
   758         set(SOURCE_FILES ${SOURCE_FILES}
   759             ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
   760       endif(HAVE_PTHREADS_SEM)
   761       set(HAVE_SDL_THREADS TRUE)
   762     endif(HAVE_PTHREADS)
   763   endif(PTHREADS)
   764 endmacro(CheckPTHREAD)
   765 
   766 # Requires
   767 # - nada
   768 # Optional:
   769 # Sets:
   770 # USB_LIBS
   771 # USB_CFLAGS
   772 macro(CheckUSBHID)
   773   check_library_exists(usbhid hid_init "" LIBUSBHID)
   774   if(LIBUSBHID)
   775     check_include_file(usbhid.h HAVE_USBHID_H)
   776     if(HAVE_USBHID_H)
   777       set(USB_CFLAGS "-DHAVE_USBHID_H")
   778     endif(HAVE_USBHID_H)
   779 
   780     check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
   781     if(HAVE_LIBUSBHID_H)
   782       set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
   783     endif(HAVE_LIBUSBHID_H)
   784     set(USB_LIBS ${USB_LIBS} usbhid)
   785   else(LIBUSBHID)
   786     check_include_file(usb.h HAVE_USB_H)
   787     if(HAVE_USB_H)
   788       set(USB_CFLAGS "-DHAVE_USB_H")
   789     endif(HAVE_USB_H)
   790     check_include_file(libusb.h HAVE_LIBUSB_H)
   791     if(HAVE_LIBUSB_H)
   792       set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
   793     endif(HAVE_LIBUSB_H)
   794     check_library_exists(usb hid_init "" LIBUSB)
   795     if(LIBUSB)
   796       set(USB_LIBS ${USB_LIBS} usb)
   797     endif(LIBUSB)
   798   endif(LIBUSBHID)
   799 
   800   set(CMAKE_REQUIRED_FLAGS "${USB_CFLAGS}")
   801   set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
   802   check_c_source_compiles("
   803        #include <sys/types.h>
   804         #if defined(HAVE_USB_H)
   805         #include <usb.h>
   806         #endif
   807         #ifdef __DragonFly__
   808         # include <bus/usb/usb.h>
   809         # include <bus/usb/usbhid.h>
   810         #else
   811         # include <dev/usb/usb.h>
   812         # include <dev/usb/usbhid.h>
   813         #endif
   814         #if defined(HAVE_USBHID_H)
   815         #include <usbhid.h>
   816         #elif defined(HAVE_LIBUSB_H)
   817         #include <libusb.h>
   818         #elif defined(HAVE_LIBUSBHID_H)
   819         #include <libusbhid.h>
   820         #endif
   821         int main(int argc, char **argv) {
   822           struct report_desc *repdesc;
   823           struct usb_ctl_report *repbuf;
   824           hid_kind_t hidkind;
   825           return 0;
   826         }" HAVE_USBHID)
   827   if(HAVE_USBHID)
   828     check_c_source_compiles("
   829           #include <sys/types.h>
   830           #if defined(HAVE_USB_H)
   831           #include <usb.h>
   832           #endif
   833           #ifdef __DragonFly__
   834           # include <bus/usb/usb.h>
   835           # include <bus/usb/usbhid.h>
   836           #else
   837           # include <dev/usb/usb.h>
   838           # include <dev/usb/usbhid.h>
   839           #endif
   840           #if defined(HAVE_USBHID_H)
   841           #include <usbhid.h>
   842           #elif defined(HAVE_LIBUSB_H)
   843           #include <libusb.h>
   844           #elif defined(HAVE_LIBUSBHID_H)
   845           #include <libusbhid.h>
   846           #endif
   847           int main(int argc, char** argv) {
   848             struct usb_ctl_report buf;
   849             if (buf.ucr_data) { }
   850             return 0;
   851           }" HAVE_USBHID_UCR_DATA)
   852     if(HAVE_USBHID_UCR_DATA)
   853       set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
   854     endif(HAVE_USBHID_UCR_DATA)
   855 
   856     check_c_source_compiles("
   857           #include <sys/types.h>
   858           #if defined(HAVE_USB_H)
   859           #include <usb.h>
   860           #endif
   861           #ifdef __DragonFly__
   862           #include <bus/usb/usb.h>
   863           #include <bus/usb/usbhid.h>
   864           #else
   865           #include <dev/usb/usb.h>
   866           #include <dev/usb/usbhid.h>
   867           #endif
   868           #if defined(HAVE_USBHID_H)
   869           #include <usbhid.h>
   870           #elif defined(HAVE_LIBUSB_H)
   871           #include <libusb.h>
   872           #elif defined(HAVE_LIBUSBHID_H)
   873           #include <libusbhid.h>
   874           #endif
   875           int main(int argc, char **argv) {
   876             report_desc_t d;
   877             hid_start_parse(d, 1, 1);
   878             return 0;
   879           }" HAVE_USBHID_NEW)
   880     if(HAVE_USBHID_NEW)
   881       set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
   882     endif(HAVE_USBHID_NEW)
   883 
   884     check_c_source_compiles("
   885         #include <machine/joystick.h>
   886         int main(int argc, char** argv) {
   887             struct joystick t;
   888             return 0;
   889         }" HAVE_MACHINE_JOYSTICK)
   890     if(HAVE_MACHINE_JOYSTICK)
   891       set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1)
   892     endif(HAVE_MACHINE_JOYSTICK)
   893     set(SDL_JOYSTICK_USBHID 1)
   894     file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
   895     set(SOURCE_FILES ${SOURCE_FILES} ${BSD_JOYSTICK_SOURCES})
   896     list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
   897     list(APPEND EXTRA_LIBS ${USB_LIBS})
   898     set(HAVE_SDL_JOYSTICK TRUE)
   899 
   900     set(CMAKE_REQUIRED_LIBRARIES)
   901     set(CMAKE_REQUIRED_FLAGS)
   902   endif(HAVE_USBHID)
   903 endmacro(CheckUSBHID)