diff options
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | externals/libusb/CMakeLists.txt | 147 | ||||
| -rw-r--r-- | externals/libusb/config.h.in | 90 | ||||
| m--------- | externals/libusb/libusb | 0 |
4 files changed, 240 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules index 6fa823c1c..9d9356151 100644 --- a/.gitmodules +++ b/.gitmodules | |||
| @@ -16,6 +16,9 @@ | |||
| 16 | [submodule "libressl"] | 16 | [submodule "libressl"] |
| 17 | path = externals/libressl | 17 | path = externals/libressl |
| 18 | url = https://github.com/citra-emu/ext-libressl-portable.git | 18 | url = https://github.com/citra-emu/ext-libressl-portable.git |
| 19 | [submodule "libusb"] | ||
| 20 | path = externals/libusb/libusb | ||
| 21 | url = https://github.com/libusb/libusb.git | ||
| 19 | [submodule "discord-rpc"] | 22 | [submodule "discord-rpc"] |
| 20 | path = externals/discord-rpc | 23 | path = externals/discord-rpc |
| 21 | url = https://github.com/discordapp/discord-rpc.git | 24 | url = https://github.com/discordapp/discord-rpc.git |
diff --git a/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt new file mode 100644 index 000000000..074ce01d3 --- /dev/null +++ b/externals/libusb/CMakeLists.txt | |||
| @@ -0,0 +1,147 @@ | |||
| 1 | add_library(usb STATIC EXCLUDE_FROM_ALL | ||
| 2 | libusb/libusb/core.c | ||
| 3 | libusb/libusb/core.c | ||
| 4 | libusb/libusb/descriptor.c | ||
| 5 | libusb/libusb/hotplug.c | ||
| 6 | libusb/libusb/io.c | ||
| 7 | libusb/libusb/strerror.c | ||
| 8 | libusb/libusb/sync.c | ||
| 9 | ) | ||
| 10 | set_target_properties(usb PROPERTIES VERSION 1.0.23) | ||
| 11 | if(WIN32) | ||
| 12 | target_include_directories(usb | ||
| 13 | BEFORE | ||
| 14 | PUBLIC | ||
| 15 | libusb/libusb | ||
| 16 | |||
| 17 | PRIVATE | ||
| 18 | "${CMAKE_CURRENT_BINARY_DIR}" | ||
| 19 | ) | ||
| 20 | |||
| 21 | if (NOT MINGW) | ||
| 22 | target_include_directories(usb BEFORE PRIVATE libusb/msvc) | ||
| 23 | endif() | ||
| 24 | else() | ||
| 25 | target_include_directories(usb | ||
| 26 | # turns out other projects also have "config.h", so make sure the | ||
| 27 | # LibUSB one comes first | ||
| 28 | BEFORE | ||
| 29 | |||
| 30 | PUBLIC | ||
| 31 | libusb/libusb | ||
| 32 | |||
| 33 | PRIVATE | ||
| 34 | "${CMAKE_CURRENT_BINARY_DIR}" | ||
| 35 | ) | ||
| 36 | endif() | ||
| 37 | |||
| 38 | if(WIN32 OR CYGWIN) | ||
| 39 | target_sources(usb PRIVATE | ||
| 40 | libusb/libusb/os/threads_windows.c | ||
| 41 | libusb/libusb/os/windows_winusb.c | ||
| 42 | libusb/libusb/os/windows_usbdk.c | ||
| 43 | libusb/libusb/os/windows_nt_common.c | ||
| 44 | ) | ||
| 45 | set(OS_WINDOWS TRUE) | ||
| 46 | elseif(APPLE) | ||
| 47 | target_sources(usb PRIVATE | ||
| 48 | libusb/libusb/os/darwin_usb.c | ||
| 49 | ) | ||
| 50 | find_library(COREFOUNDATION_LIBRARY CoreFoundation) | ||
| 51 | find_library(IOKIT_LIBRARY IOKit) | ||
| 52 | find_library(OBJC_LIBRARY objc) | ||
| 53 | target_link_libraries(usb PRIVATE | ||
| 54 | ${COREFOUNDATION_LIBRARY} | ||
| 55 | ${IOKIT_LIBRARY} | ||
| 56 | ${OBJC_LIBRARY} | ||
| 57 | ) | ||
| 58 | set(OS_DARWIN TRUE) | ||
| 59 | elseif(ANDROID) | ||
| 60 | target_sources(usb PRIVATE | ||
| 61 | libusb/libusb/os/linux_usbfs.c | ||
| 62 | libusb/libusb/os/linux_netlink.c | ||
| 63 | ) | ||
| 64 | find_library(LOG_LIBRARY log) | ||
| 65 | target_link_libraries(usb PRIVATE ${LOG_LIBRARY}) | ||
| 66 | set(OS_LINUX TRUE) | ||
| 67 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
| 68 | target_sources(usb PRIVATE | ||
| 69 | libusb/libusb/os/linux_usbfs.c | ||
| 70 | ) | ||
| 71 | find_package(Libudev) | ||
| 72 | if(LIBUDEV_FOUND) | ||
| 73 | target_sources(usb PRIVATE | ||
| 74 | libusb/libusb/os/linux_udev.c | ||
| 75 | ) | ||
| 76 | target_link_libraries(usb PRIVATE "${LIBUDEV_LIBRARIES}") | ||
| 77 | target_include_directories(usb PRIVATE "${LIBUDEV_INCLUDE_DIR}") | ||
| 78 | set(HAVE_LIBUDEV TRUE) | ||
| 79 | set(USE_UDEV TRUE) | ||
| 80 | else() | ||
| 81 | target_sources(usb PRIVATE | ||
| 82 | libusb/libusb/os/linux_netlink.c | ||
| 83 | ) | ||
| 84 | endif() | ||
| 85 | set(OS_LINUX TRUE) | ||
| 86 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") | ||
| 87 | target_sources(usb PRIVATE | ||
| 88 | libusb/libusb/os/netbsd_usb.c | ||
| 89 | ) | ||
| 90 | set(OS_NETBSD TRUE) | ||
| 91 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") | ||
| 92 | target_sources(usb PRIVATE | ||
| 93 | libusb/libusb/os/openbsd_usb.c | ||
| 94 | ) | ||
| 95 | set(OS_OPENBSD TRUE) | ||
| 96 | endif() | ||
| 97 | |||
| 98 | if(UNIX) | ||
| 99 | target_sources(usb PRIVATE | ||
| 100 | libusb/libusb/os/poll_posix.c | ||
| 101 | libusb/libusb/os/threads_posix.c | ||
| 102 | ) | ||
| 103 | find_package(Threads REQUIRED) | ||
| 104 | if(THREADS_HAVE_PTHREAD_ARG) | ||
| 105 | target_compile_options(usb PUBLIC "-pthread") | ||
| 106 | endif() | ||
| 107 | if(CMAKE_THREAD_LIBS_INIT) | ||
| 108 | target_link_libraries(usb PRIVATE "${CMAKE_THREAD_LIBS_INIT}") | ||
| 109 | endif() | ||
| 110 | set(THREADS_POSIX TRUE) | ||
| 111 | elseif(WIN32) | ||
| 112 | target_sources(usb PRIVATE | ||
| 113 | libusb/libusb/os/poll_windows.c | ||
| 114 | libusb/libusb/os/threads_windows.c | ||
| 115 | ) | ||
| 116 | endif() | ||
| 117 | |||
| 118 | include(CheckFunctionExists) | ||
| 119 | include(CheckIncludeFiles) | ||
| 120 | include(CheckTypeSize) | ||
| 121 | check_include_files(asm/types.h HAVE_ASM_TYPES_H) | ||
| 122 | check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) | ||
| 123 | check_include_files(linux/filter.h HAVE_LINUX_FILTER_H) | ||
| 124 | check_include_files(linux/netlink.h HAVE_LINUX_NETLINK_H) | ||
| 125 | check_include_files(poll.h HAVE_POLL_H) | ||
| 126 | check_include_files(signal.h HAVE_SIGNAL_H) | ||
| 127 | check_include_files(strings.h HAVE_STRINGS_H) | ||
| 128 | check_type_size("struct timespec" STRUCT_TIMESPEC) | ||
| 129 | check_function_exists(syslog HAVE_SYSLOG_FUNC) | ||
| 130 | check_include_files(syslog.h HAVE_SYSLOG_H) | ||
| 131 | check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) | ||
| 132 | check_include_files(sys/time.h HAVE_SYS_TIME_H) | ||
| 133 | check_include_files(sys/types.h HAVE_SYS_TYPES_H) | ||
| 134 | |||
| 135 | set(CMAKE_EXTRA_INCLUDE_FILES poll.h) | ||
| 136 | check_type_size("nfds_t" nfds_t) | ||
| 137 | unset(CMAKE_EXTRA_INCLUDE_FILES) | ||
| 138 | if(HAVE_NFDS_T) | ||
| 139 | set(POLL_NFDS_TYPE "nfds_t") | ||
| 140 | else() | ||
| 141 | set(POLL_NFDS_TYPE "unsigned int") | ||
| 142 | endif() | ||
| 143 | |||
| 144 | check_include_files(sys/timerfd.h USBI_TIMERFD_AVAILABLE) | ||
| 145 | |||
| 146 | |||
| 147 | configure_file(config.h.in config.h) | ||
diff --git a/externals/libusb/config.h.in b/externals/libusb/config.h.in new file mode 100644 index 000000000..915b7390f --- /dev/null +++ b/externals/libusb/config.h.in | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | /* Default visibility */ | ||
| 2 | #if defined(__GNUC__) || defined(__clang__) | ||
| 3 | #define DEFAULT_VISIBILITY __attribute__((visibility("default"))) | ||
| 4 | #elif defined(_MSC_VER) | ||
| 5 | #define DEFAULT_VISIBILITY __declspec(dllexport) | ||
| 6 | #endif | ||
| 7 | |||
| 8 | /* Start with debug message logging enabled */ | ||
| 9 | #undef ENABLE_DEBUG_LOGGING | ||
| 10 | |||
| 11 | /* Message logging */ | ||
| 12 | #undef ENABLE_LOGGING | ||
| 13 | |||
| 14 | /* Define to 1 if you have the <asm/types.h> header file. */ | ||
| 15 | #cmakedefine HAVE_ASM_TYPES_H 1 | ||
| 16 | |||
| 17 | /* Define to 1 if you have the `gettimeofday' function. */ | ||
| 18 | #cmakedefine HAVE_GETTIMEOFDAY 1 | ||
| 19 | |||
| 20 | /* Define to 1 if you have the `udev' library (-ludev). */ | ||
| 21 | #cmakedefine HAVE_LIBUDEV 1 | ||
| 22 | |||
| 23 | /* Define to 1 if you have the <linux/filter.h> header file. */ | ||
| 24 | #cmakedefine HAVE_LINUX_FILTER_H 1 | ||
| 25 | |||
| 26 | /* Define to 1 if you have the <linux/netlink.h> header file. */ | ||
| 27 | #cmakedefine HAVE_LINUX_NETLINK_H 1 | ||
| 28 | |||
| 29 | /* Define to 1 if you have the <poll.h> header file. */ | ||
| 30 | #cmakedefine HAVE_POLL_H 1 | ||
| 31 | |||
| 32 | /* Define to 1 if you have the <signal.h> header file. */ | ||
| 33 | #cmakedefine HAVE_SIGNAL_H 1 | ||
| 34 | |||
| 35 | /* Define to 1 if you have the <strings.h> header file. */ | ||
| 36 | #cmakedefine HAVE_STRINGS_H 1 | ||
| 37 | |||
| 38 | /* Define to 1 if the system has the type `struct timespec'. */ | ||
| 39 | #cmakedefine HAVE_STRUCT_TIMESPEC 1 | ||
| 40 | |||
| 41 | /* syslog() function available */ | ||
| 42 | #cmakedefine HAVE_SYSLOG_FUNC 1 | ||
| 43 | |||
| 44 | /* Define to 1 if you have the <syslog.h> header file. */ | ||
| 45 | #cmakedefine HAVE_SYSLOG_H 1 | ||
| 46 | |||
| 47 | /* Define to 1 if you have the <sys/socket.h> header file. */ | ||
| 48 | #cmakedefine HAVE_SYS_SOCKET_H 1 | ||
| 49 | |||
| 50 | /* Define to 1 if you have the <sys/time.h> header file. */ | ||
| 51 | #cmakedefine HAVE_SYS_TIME_H 1 | ||
| 52 | |||
| 53 | /* Define to 1 if you have the <sys/types.h> header file. */ | ||
| 54 | #cmakedefine HAVE_SYS_TYPES_H 1 | ||
| 55 | |||
| 56 | /* Darwin backend */ | ||
| 57 | #cmakedefine OS_DARWIN 1 | ||
| 58 | |||
| 59 | /* Linux backend */ | ||
| 60 | #cmakedefine OS_LINUX 1 | ||
| 61 | |||
| 62 | /* NetBSD backend */ | ||
| 63 | #cmakedefine OS_NETBSD 1 | ||
| 64 | |||
| 65 | /* OpenBSD backend */ | ||
| 66 | #cmakedefine OS_OPENBSD 1 | ||
| 67 | |||
| 68 | /* Windows backend */ | ||
| 69 | #cmakedefine OS_WINDOWS 1 | ||
| 70 | |||
| 71 | /* type of second poll() argument */ | ||
| 72 | #define POLL_NFDS_TYPE @POLL_NFDS_TYPE@ | ||
| 73 | |||
| 74 | /* Use POSIX Threads */ | ||
| 75 | #cmakedefine THREADS_POSIX | ||
| 76 | |||
| 77 | /* timerfd headers available */ | ||
| 78 | #cmakedefine USBI_TIMERFD_AVAILABLE 1 | ||
| 79 | |||
| 80 | /* Enable output to system log */ | ||
| 81 | #define USE_SYSTEM_LOGGING_FACILITY 1 | ||
| 82 | |||
| 83 | /* Use udev for device enumeration/hotplug */ | ||
| 84 | #cmakedefine USE_UDEV 1 | ||
| 85 | |||
| 86 | /* Use GNU extensions */ | ||
| 87 | #define _GNU_SOURCE | ||
| 88 | |||
| 89 | /* Oldest Windows version supported */ | ||
| 90 | #define WINVER 0x0501 | ||
diff --git a/externals/libusb/libusb b/externals/libusb/libusb new file mode 160000 | |||
| Subproject e782eeb2514266f6738e242cdcb18e3ae1ed06f | |||