diff options
Diffstat (limited to 'externals/libusb/CMakeLists.txt')
| m--------- | externals/libusb | 0 | ||||
| -rw-r--r-- | externals/libusb/CMakeLists.txt | 147 |
2 files changed, 147 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..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) | ||