cmake/sdlchecks.cmake
changeset 12932 800524378309
parent 12391 ca6e41ade79a
child 12971 2fbd3d8432ab
     1.1 --- a/cmake/sdlchecks.cmake	Mon Jul 08 16:08:16 2019 -0400
     1.2 +++ b/cmake/sdlchecks.cmake	Mon Jul 08 16:46:52 2019 -0400
     1.3 @@ -1065,6 +1065,37 @@
     1.4    endif()
     1.5  endmacro()
     1.6  
     1.7 +# Check for HIDAPI joystick drivers. This is currently a Unix thing, not Windows or macOS!
     1.8 +macro(CheckHIDAPI)
     1.9 +  if(HIDAPI)
    1.10 +    if(HIDAPI_SKIP_LIBUSB)
    1.11 +      set(HAVE_HIDAPI TRUE)
    1.12 +    else()
    1.13 +      set(HAVE_HIDAPI FALSE)
    1.14 +      pkg_check_modules(LIBUSB libusb)
    1.15 +      if (LIBUSB_FOUND)
    1.16 +        check_include_file(libusb.h HAVE_LIBUSB_H)
    1.17 +        if (HAVE_LIBUSB_H)
    1.18 +          set(HAVE_HIDAPI TRUE)
    1.19 +        endif()
    1.20 +      endif()
    1.21 +    endif()
    1.22 +
    1.23 +    if(HAVE_HIDAPI)
    1.24 +      set(SDL_JOYSTICK_HIDAPI 1)
    1.25 +      set(HAVE_SDL_JOYSTICK TRUE)
    1.26 +      file(GLOB HIDAPI_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
    1.27 +      set(SOURCE_FILES ${SOURCE_FILES} ${HIDAPI_SOURCES})
    1.28 +      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS} -I${SDL2_SOURCE_DIR}/src/hidapi/hidapi")
    1.29 +      if(NOT HIDAPI_SKIP_LIBUSB)
    1.30 +        set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/libusb/hid.c)
    1.31 +        list(APPEND EXTRA_LIBS ${LIBUSB_LIBS})
    1.32 +      endif()
    1.33 +    endif()
    1.34 +  endif()
    1.35 +endmacro()
    1.36 +
    1.37 +
    1.38  # Requires:
    1.39  # - n/a
    1.40  macro(CheckRPI)