Fixed building on Windows with CMake
authorSam Lantinga <slouken@libsdl.org>
Sat, 16 Aug 2014 15:18:21 -0700
changeset 9073 98d13a381299
parent 9072 0c1a46c018aa
child 9074 86a6f6d92960
Fixed building on Windows with CMake
CMakeLists.txt
--- a/CMakeLists.txt	Sat Aug 16 16:50:10 2014 -0400
+++ b/CMakeLists.txt	Sat Aug 16 15:18:21 2014 -0700
@@ -805,6 +805,7 @@
     check_include_file(dsound.h HAVE_DSOUND_H)
     check_include_file(dinput.h HAVE_DINPUT_H)
     check_include_file(xaudio2.h HAVE_XAUDIO2_H)
+    check_include_file(xinput.h HAVE_XINPUT_H)
     check_include_file(dxgi.h HAVE_DXGI_H)
     if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
       set(HAVE_DIRECTX TRUE)
@@ -910,21 +911,31 @@
   endif()
 
   if(SDL_JOYSTICK)
+    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c)
+    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
     if(HAVE_DINPUT_H)
       set(SDL_JOYSTICK_DINPUT 1)
-      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_dxjoystick.c)
       list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
-    else()
+    endif()
+    if(HAVE_XINPUT_H)
+      set(SDL_JOYSTICK_XINPUT 1)
+    endif()
+    if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H)
       set(SDL_JOYSTICK_WINMM 1)
-      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_mmjoystick.c)
     endif()
     set(HAVE_SDL_JOYSTICK TRUE)
-  endif()
 
-  if(SDL_HAPTIC AND HAVE_DINPUT_H)
-    set(SDL_HAPTIC_DINPUT 1)
-    set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/haptic/windows/SDL_syshaptic.c)
-    set(HAVE_SDL_HAPTIC TRUE)
+    if(SDL_HAPTIC)
+      file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/windows/*.c)
+      set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
+      if(HAVE_DINPUT_H)
+        set(SDL_HAPTIC_DINPUT 1)
+      endif()
+      if(HAVE_XINPUT_H)
+        set(SDL_HAPTIC_XINPUT 1)
+      endif()
+      set(HAVE_SDL_HAPTIC TRUE)
+    endif()
   endif()
 
   file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)