cmake: enable disabing hidapi
parent
a4e6f3ca9d
commit
17b329d199
|
@ -515,10 +515,12 @@ set_option(SDL_INSTALL_TESTS "Install test-cases" OFF)
|
|||
|
||||
set(HAVE_STATIC_PIC "${SDL_STATIC_PIC}")
|
||||
|
||||
if(HIDAPI_ONLY_LIBUSB)
|
||||
set(SDL_HIDAPI_LIBUSB ON CACHE BOOL "" FORCE)
|
||||
elseif(HIDAPI_SKIP_LIBUSB)
|
||||
set(SDL_HIDAPI_LIBUSB OFF CACHE BOOL "" FORCE)
|
||||
if(SDL_HIDAPI)
|
||||
if(HIDAPI_ONLY_LIBUSB)
|
||||
set(SDL_HIDAPI_LIBUSB ON CACHE BOOL "" FORCE)
|
||||
elseif(HIDAPI_SKIP_LIBUSB)
|
||||
set(SDL_HIDAPI_LIBUSB OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(VITA)
|
||||
|
|
|
@ -1176,49 +1176,53 @@ endmacro()
|
|||
# Check for HIDAPI support
|
||||
macro(CheckHIDAPI)
|
||||
set(HAVE_HIDAPI TRUE)
|
||||
if(SDL_HIDAPI_LIBUSB)
|
||||
set(HAVE_LIBUSB FALSE)
|
||||
pkg_check_modules(LIBUSB libusb-1.0)
|
||||
if(LIBUSB_FOUND)
|
||||
check_include_file(libusb.h HAVE_LIBUSB_H ${LIBUSB_CFLAGS})
|
||||
if(HAVE_LIBUSB_H)
|
||||
set(HAVE_LIBUSB TRUE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS}")
|
||||
if(HIDAPI_ONLY_LIBUSB)
|
||||
list(APPEND EXTRA_LIBS ${LIBUSB_LIBS})
|
||||
elseif(OS2)
|
||||
set(SDL_LIBUSB_DYNAMIC "\"usb100.dll\"")
|
||||
else()
|
||||
# libusb is loaded dynamically, so don't add it to EXTRA_LIBS
|
||||
FindLibraryAndSONAME("usb-1.0")
|
||||
if(USB_1.0_LIB)
|
||||
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
|
||||
if(SDL_HIDAPI)
|
||||
if(SDL_HIDAPI_LIBUSB)
|
||||
set(HAVE_LIBUSB FALSE)
|
||||
pkg_check_modules(LIBUSB libusb-1.0)
|
||||
if(LIBUSB_FOUND)
|
||||
check_include_file(libusb.h HAVE_LIBUSB_H ${LIBUSB_CFLAGS})
|
||||
if(HAVE_LIBUSB_H)
|
||||
set(HAVE_LIBUSB TRUE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS}")
|
||||
if(HIDAPI_ONLY_LIBUSB)
|
||||
list(APPEND EXTRA_LIBS ${LIBUSB_LIBS})
|
||||
elseif(OS2)
|
||||
set(SDL_LIBUSB_DYNAMIC "\"usb100.dll\"")
|
||||
else()
|
||||
# libusb is loaded dynamically, so don't add it to EXTRA_LIBS
|
||||
FindLibraryAndSONAME("usb-1.0")
|
||||
if(USB_1.0_LIB)
|
||||
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(HIDAPI_ONLY_LIBUSB AND NOT HAVE_LIBUSB)
|
||||
set(HAVE_HIDAPI FALSE)
|
||||
endif()
|
||||
endif()
|
||||
if(HIDAPI_ONLY_LIBUSB AND NOT HAVE_LIBUSB)
|
||||
set(HAVE_HIDAPI FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_HIDAPI)
|
||||
if(ANDROID)
|
||||
list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp)
|
||||
endif()
|
||||
if(IOS OR TVOS)
|
||||
list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/ios/hid.m)
|
||||
set(SDL_FRAMEWORK_COREBLUETOOTH 1)
|
||||
endif()
|
||||
set(HAVE_SDL_HIDAPI TRUE)
|
||||
if(HAVE_HIDAPI)
|
||||
if(ANDROID)
|
||||
list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp)
|
||||
endif()
|
||||
if(IOS OR TVOS)
|
||||
list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/ios/hid.m)
|
||||
set(SDL_FRAMEWORK_COREBLUETOOTH 1)
|
||||
endif()
|
||||
set(HAVE_SDL_HIDAPI TRUE)
|
||||
|
||||
if(SDL_JOYSTICK AND SDL_HIDAPI_JOYSTICK)
|
||||
set(SDL_JOYSTICK_HIDAPI 1)
|
||||
set(HAVE_SDL_JOYSTICK TRUE)
|
||||
set(HAVE_HIDAPI_JOYSTICK TRUE)
|
||||
file(GLOB HIDAPI_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
|
||||
list(APPEND SOURCE_FILES ${HIDAPI_JOYSTICK_SOURCES})
|
||||
if(SDL_JOYSTICK AND SDL_HIDAPI_JOYSTICK)
|
||||
set(SDL_JOYSTICK_HIDAPI 1)
|
||||
set(HAVE_SDL_JOYSTICK TRUE)
|
||||
set(HAVE_HIDAPI_JOYSTICK TRUE)
|
||||
file(GLOB HIDAPI_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
|
||||
list(APPEND SOURCE_FILES ${HIDAPI_JOYSTICK_SOURCES})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set(SDL_HIDAPI_DISABLED 1)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
|
Loading…
Reference in New Issue