diff options
Diffstat (limited to 'externals/libusb/CMakeLists.txt')
| m--------- | externals/libusb | 0 | ||||
| -rw-r--r-- | externals/libusb/CMakeLists.txt | 150 |
2 files changed, 150 insertions, 0 deletions
diff --git a/externals/libusb b/externals/libusb deleted file mode 160000 | |||
| Subproject 3406d72cda879f8792a88bf5f6bd0b7a65636f7 | |||
diff --git a/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt new file mode 100644 index 000000000..c0d24b126 --- /dev/null +++ b/externals/libusb/CMakeLists.txt | |||
| @@ -0,0 +1,150 @@ | |||
| 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 | |||
| 25 | # Works around other libraries providing their own definition of USB GUIDs (e.g. SDL2) | ||
| 26 | target_compile_definitions(usb PRIVATE "-DGUID_DEVINTERFACE_USB_DEVICE=(GUID){ 0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}}") | ||
| 27 | else() | ||
| 28 | target_include_directories(usb | ||
| 29 | # turns out other projects also have "config.h", so make sure the | ||
| 30 | # LibUSB one comes first | ||
| 31 | BEFORE | ||
| 32 | |||
| 33 | PUBLIC | ||
| 34 | libusb/libusb | ||
| 35 | |||
| 36 | PRIVATE | ||
| 37 | "${CMAKE_CURRENT_BINARY_DIR}" | ||
| 38 | ) | ||
| 39 | endif() | ||
| 40 | |||
| 41 | if(WIN32 OR CYGWIN) | ||
| 42 | target_sources(usb PRIVATE | ||
| 43 | libusb/libusb/os/threads_windows.c | ||
| 44 | libusb/libusb/os/windows_winusb.c | ||
| 45 | libusb/libusb/os/windows_usbdk.c | ||
| 46 | libusb/libusb/os/windows_nt_common.c | ||
| 47 | ) | ||
| 48 | set(OS_WINDOWS TRUE) | ||
| 49 | elseif(APPLE) | ||
| 50 | target_sources(usb PRIVATE | ||
| 51 | libusb/libusb/os/darwin_usb.c | ||
| 52 | ) | ||
| 53 | find_library(COREFOUNDATION_LIBRARY CoreFoundation) | ||
| 54 | find_library(IOKIT_LIBRARY IOKit) | ||
| 55 | find_library(OBJC_LIBRARY objc) | ||
| 56 | target_link_libraries(usb PRIVATE | ||
| 57 | ${COREFOUNDATION_LIBRARY} | ||
| 58 | ${IOKIT_LIBRARY} | ||
| 59 | ${OBJC_LIBRARY} | ||
| 60 | ) | ||
| 61 | set(OS_DARWIN TRUE) | ||
| 62 | elseif(ANDROID) | ||
| 63 | target_sources(usb PRIVATE | ||
| 64 | libusb/libusb/os/linux_usbfs.c | ||
| 65 | libusb/libusb/os/linux_netlink.c | ||
| 66 | ) | ||
| 67 | find_library(LOG_LIBRARY log) | ||
| 68 | target_link_libraries(usb PRIVATE ${LOG_LIBRARY}) | ||
| 69 | set(OS_LINUX TRUE) | ||
| 70 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
| 71 | target_sources(usb PRIVATE | ||
| 72 | libusb/libusb/os/linux_usbfs.c | ||
| 73 | ) | ||
| 74 | find_package(Libudev) | ||
| 75 | if(LIBUDEV_FOUND) | ||
| 76 | target_sources(usb PRIVATE | ||
| 77 | libusb/libusb/os/linux_udev.c | ||
| 78 | ) | ||
| 79 | target_link_libraries(usb PRIVATE "${LIBUDEV_LIBRARIES}") | ||
| 80 | target_include_directories(usb PRIVATE "${LIBUDEV_INCLUDE_DIR}") | ||
| 81 | set(HAVE_LIBUDEV TRUE) | ||
| 82 | set(USE_UDEV TRUE) | ||
| 83 | else() | ||
| 84 | target_sources(usb PRIVATE | ||
| 85 | libusb/libusb/os/linux_netlink.c | ||
| 86 | ) | ||
| 87 | endif() | ||
| 88 | set(OS_LINUX TRUE) | ||
| 89 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") | ||
| 90 | target_sources(usb PRIVATE | ||
| 91 | libusb/libusb/os/netbsd_usb.c | ||
| 92 | ) | ||
| 93 | set(OS_NETBSD TRUE) | ||
| 94 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") | ||
| 95 | target_sources(usb PRIVATE | ||
| 96 | libusb/libusb/os/openbsd_usb.c | ||
| 97 | ) | ||
| 98 | set(OS_OPENBSD TRUE) | ||
| 99 | endif() | ||
| 100 | |||
| 101 | if(UNIX) | ||
| 102 | target_sources(usb PRIVATE | ||
| 103 | libusb/libusb/os/poll_posix.c | ||
| 104 | libusb/libusb/os/threads_posix.c | ||
| 105 | ) | ||
| 106 | find_package(Threads REQUIRED) | ||
| 107 | if(THREADS_HAVE_PTHREAD_ARG) | ||
| 108 | target_compile_options(usb PUBLIC "-pthread") | ||
| 109 | endif() | ||
| 110 | if(CMAKE_THREAD_LIBS_INIT) | ||
| 111 | target_link_libraries(usb PRIVATE "${CMAKE_THREAD_LIBS_INIT}") | ||
| 112 | endif() | ||
| 113 | set(THREADS_POSIX TRUE) | ||
| 114 | elseif(WIN32) | ||
| 115 | target_sources(usb PRIVATE | ||
| 116 | libusb/libusb/os/poll_windows.c | ||
| 117 | libusb/libusb/os/threads_windows.c | ||
| 118 | ) | ||
| 119 | endif() | ||
| 120 | |||
| 121 | include(CheckFunctionExists) | ||
| 122 | include(CheckIncludeFiles) | ||
| 123 | include(CheckTypeSize) | ||
| 124 | check_include_files(asm/types.h HAVE_ASM_TYPES_H) | ||
| 125 | check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) | ||
| 126 | check_include_files(linux/filter.h HAVE_LINUX_FILTER_H) | ||
| 127 | check_include_files(linux/netlink.h HAVE_LINUX_NETLINK_H) | ||
| 128 | check_include_files(poll.h HAVE_POLL_H) | ||
| 129 | check_include_files(signal.h HAVE_SIGNAL_H) | ||
| 130 | check_include_files(strings.h HAVE_STRINGS_H) | ||
| 131 | check_type_size("struct timespec" STRUCT_TIMESPEC) | ||
| 132 | check_function_exists(syslog HAVE_SYSLOG_FUNC) | ||
| 133 | check_include_files(syslog.h HAVE_SYSLOG_H) | ||
| 134 | check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) | ||
| 135 | check_include_files(sys/time.h HAVE_SYS_TIME_H) | ||
| 136 | check_include_files(sys/types.h HAVE_SYS_TYPES_H) | ||
| 137 | |||
| 138 | set(CMAKE_EXTRA_INCLUDE_FILES poll.h) | ||
| 139 | check_type_size("nfds_t" nfds_t) | ||
| 140 | unset(CMAKE_EXTRA_INCLUDE_FILES) | ||
| 141 | if(HAVE_NFDS_T) | ||
| 142 | set(POLL_NFDS_TYPE "nfds_t") | ||
| 143 | else() | ||
| 144 | set(POLL_NFDS_TYPE "unsigned int") | ||
| 145 | endif() | ||
| 146 | |||
| 147 | check_include_files(sys/timerfd.h USBI_TIMERFD_AVAILABLE) | ||
| 148 | |||
| 149 | |||
| 150 | configure_file(config.h.in config.h) | ||