summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.ci/scripts/windows/docker.sh3
-rw-r--r--CMakeLists.txt2
-rw-r--r--externals/libusb/CMakeLists.txt360
3 files changed, 226 insertions, 139 deletions
diff --git a/.ci/scripts/windows/docker.sh b/.ci/scripts/windows/docker.sh
index 192a01fd8..feba3fd6e 100755
--- a/.ci/scripts/windows/docker.sh
+++ b/.ci/scripts/windows/docker.sh
@@ -47,3 +47,6 @@ python3 .ci/scripts/windows/scan_dll.py package/imageformats/*.dll "package/"
47EXTERNALS_PATH="$(pwd)/build/externals" 47EXTERNALS_PATH="$(pwd)/build/externals"
48FFMPEG_DLL_PATH="$(find ${EXTERNALS_PATH} -maxdepth 1 -type d | grep ffmpeg)/bin" 48FFMPEG_DLL_PATH="$(find ${EXTERNALS_PATH} -maxdepth 1 -type d | grep ffmpeg)/bin"
49find ${FFMPEG_DLL_PATH} -type f -regex ".*\.dll" -exec cp -v {} package/ ';' 49find ${FFMPEG_DLL_PATH} -type f -regex ".*\.dll" -exec cp -v {} package/ ';'
50
51# copy libraries from yuzu.exe path
52find "$(pwd)/build/bin/" -type f -regex ".*\.dll" -exec cp -v {} package/ ';'
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 10c5032dc..ba207dfd1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -426,7 +426,7 @@ if(NOT APPLE)
426endif() 426endif()
427if (NOT LIBUSB_FOUND) 427if (NOT LIBUSB_FOUND)
428 add_subdirectory(externals/libusb) 428 add_subdirectory(externals/libusb)
429 set(LIBUSB_INCLUDE_DIR "") 429 set(LIBUSB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/externals/libusb/libusb/libusb")
430 set(LIBUSB_LIBRARIES usb) 430 set(LIBUSB_LIBRARIES usb)
431endif() 431endif()
432 432
diff --git a/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt
index 8ed40f01e..3ef007b40 100644
--- a/externals/libusb/CMakeLists.txt
+++ b/externals/libusb/CMakeLists.txt
@@ -1,155 +1,239 @@
1# Ensure libusb compiles with UTF-8 encoding on MSVC 1if (MINGW)
2if(MSVC) 2 # The MinGW toolchain for some reason doesn't work with this CMakeLists file after updating to
3 add_compile_options(/utf-8) 3 # 1.0.24, so we do it the old-fashioned way for now. We may want to move native Linux toolchains
4endif() 4 # to here, too (TODO lat9nq?).
5 5
6add_library(usb STATIC EXCLUDE_FROM_ALL 6 set(LIBUSB_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libusb")
7 libusb/libusb/core.c 7 set(LIBUSB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libusb")
8 libusb/libusb/core.c 8 # Workarounds for MSYS/MinGW
9 libusb/libusb/descriptor.c 9 if (MSYS)
10 libusb/libusb/hotplug.c 10 # CMake on Windows passes `C:/`, but we need `/C/` or `/c/` to use `configure`
11 libusb/libusb/io.c 11 string(REPLACE ":/" "/" LIBUSB_SRC_DIR "${LIBUSB_SRC_DIR}")
12 libusb/libusb/strerror.c 12 set(LIBUSB_SRC_DIR "/${LIBUSB_SRC_DIR}")
13 libusb/libusb/sync.c
14)
15set_target_properties(usb PROPERTIES VERSION 1.0.23)
16if(WIN32)
17 target_include_directories(usb
18 BEFORE
19 PUBLIC
20 libusb/libusb
21
22 PRIVATE
23 "${CMAKE_CURRENT_BINARY_DIR}"
24 )
25 13
26 if (NOT MINGW) 14 # And now that we are using /C/ for srcdir but everything else is using C:/, we need to
27 target_include_directories(usb BEFORE PRIVATE libusb/msvc) 15 # compile everything in the source directory, else `configure` won't think the build
16 # environment is sane.
17 set(LIBUSB_PREFIX "${LIBUSB_SRC_DIR}")
28 endif() 18 endif()
29 19
30 # Works around other libraries providing their own definition of USB GUIDs (e.g. SDL2) 20 set(LIBUSB_CONFIGURE "${LIBUSB_SRC_DIR}/configure")
31 target_compile_definitions(usb PRIVATE "-DGUID_DEVINTERFACE_USB_DEVICE=(GUID){ 0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}}") 21 set(LIBUSB_MAKEFILE "${LIBUSB_PREFIX}/Makefile")
32else() 22 set(LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll.a")
33target_include_directories(usb 23 set(LIBUSB_SHARED_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll")
34 # turns out other projects also have "config.h", so make sure the 24 set(LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.dll")
35 # LibUSB one comes first 25
36 BEFORE 26 # Causes "externals/libusb/libusb/libusb/os/windows_winusb.c:1427:2: error: conversion to non-scalar type requested", so cannot statically link it for now.
37 27 # set(LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}")
38 PUBLIC 28
39 libusb/libusb 29 make_directory("${LIBUSB_PREFIX}")
40 30
41 PRIVATE 31 add_custom_command(
42 "${CMAKE_CURRENT_BINARY_DIR}" 32 OUTPUT
43) 33 "${LIBUSB_LIBRARY}"
44endif() 34 COMMAND
45 35 make
46if(WIN32 OR CYGWIN) 36 WORKING_DIRECTORY
47 target_sources(usb PRIVATE 37 "${LIBUSB_PREFIX}"
48 libusb/libusb/os/threads_windows.c
49 libusb/libusb/os/windows_winusb.c
50 libusb/libusb/os/windows_usbdk.c
51 libusb/libusb/os/windows_common.c
52 ) 38 )
53 set(OS_WINDOWS TRUE) 39
54elseif(APPLE) 40 # We may use this path for other GNU toolchains, so put all of the MinGW-specific stuff here
55 target_sources(usb PRIVATE 41 if (MINGW)
56 libusb/libusb/os/darwin_usb.c 42 set(LIBUSB_CONFIGURE_ARGS --host=x86_64-w64-mingw32 --build=x86_64-windows)
43 endif()
44
45 add_custom_command(
46 OUTPUT
47 "${LIBUSB_MAKEFILE}"
48 COMMAND
49 # /bin/env
50 # CFLAGS="${LIBUSB_CFLAGS}"
51 /bin/sh "${LIBUSB_CONFIGURE}"
52 ${LIBUSB_CONFIGURE_ARGS}
53 --srcdir="${LIBUSB_SRC_DIR}"
54 WORKING_DIRECTORY
55 "${LIBUSB_PREFIX}"
57 ) 56 )
58 find_library(COREFOUNDATION_LIBRARY CoreFoundation) 57
59 find_library(IOKIT_LIBRARY IOKit) 58 add_custom_command(
60 find_library(OBJC_LIBRARY objc) 59 OUTPUT
61 target_link_libraries(usb PRIVATE 60 "${LIBUSB_CONFIGURE}"
62 ${COREFOUNDATION_LIBRARY} 61 COMMAND
63 ${IOKIT_LIBRARY} 62 /bin/sh "${LIBUSB_SRC_DIR}/bootstrap.sh"
64 ${OBJC_LIBRARY} 63 WORKING_DIRECTORY
64 "${LIBUSB_SRC_DIR}"
65 ) 65 )
66 set(OS_DARWIN TRUE) 66
67elseif(ANDROID) 67 add_custom_command(
68 target_sources(usb PRIVATE 68 OUTPUT
69 libusb/libusb/os/linux_usbfs.c 69 "${LIBUSB_SHARED_LIBRARY_DEST}"
70 libusb/libusb/os/linux_netlink.c 70 COMMAND
71 /bin/cp "${LIBUSB_SHARED_LIBRARY}" "${LIBUSB_SHARED_LIBRARY_DEST}"
71 ) 72 )
72 find_library(LOG_LIBRARY log) 73
73 target_link_libraries(usb PRIVATE ${LOG_LIBRARY}) 74 add_custom_target(usb-bootstrap ALL DEPENDS "${LIBUSB_CONFIGURE}")
74 set(OS_LINUX TRUE) 75 add_custom_target(usb-configure ALL DEPENDS "${LIBUSB_MAKEFILE}" usb-bootstrap)
75elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 76 add_custom_target(usb-build ALL DEPENDS "${LIBUSB_LIBRARY}" usb-configure)
76 target_sources(usb PRIVATE 77 # Workaround since static linking didn't work out -- We need to copy the DLL to the bin directory
77 libusb/libusb/os/linux_usbfs.c 78 add_custom_target(usb-copy ALL DEPENDS "${LIBUSB_SHARED_LIBRARY_DEST}" usb-build)
79
80 # Make `usb` alias to LIBUSB_LIBRARY
81 add_library(usb INTERFACE)
82 target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARY}")
83else() # MINGW
84 # Ensure libusb compiles with UTF-8 encoding on MSVC
85 if(MSVC)
86 add_compile_options(/utf-8)
87 endif()
88
89 add_library(usb STATIC EXCLUDE_FROM_ALL
90 libusb/libusb/core.c
91 libusb/libusb/core.c
92 libusb/libusb/descriptor.c
93 libusb/libusb/hotplug.c
94 libusb/libusb/io.c
95 libusb/libusb/strerror.c
96 libusb/libusb/sync.c
78 ) 97 )
79 find_package(Libudev) 98 set_target_properties(usb PROPERTIES VERSION 1.0.24)
80 if(LIBUDEV_FOUND) 99 if(WIN32)
81 target_sources(usb PRIVATE 100 target_include_directories(usb
82 libusb/libusb/os/linux_udev.c 101 BEFORE
102 PUBLIC
103 libusb/libusb
104
105 PRIVATE
106 "${CMAKE_CURRENT_BINARY_DIR}"
83 ) 107 )
84 target_link_libraries(usb PRIVATE "${LIBUDEV_LIBRARIES}") 108
85 target_include_directories(usb PRIVATE "${LIBUDEV_INCLUDE_DIR}") 109 if (NOT MINGW)
86 set(HAVE_LIBUDEV TRUE) 110 target_include_directories(usb BEFORE PRIVATE libusb/msvc)
87 set(USE_UDEV TRUE) 111 endif()
112
113 # Works around other libraries providing their own definition of USB GUIDs (e.g. SDL2)
114 target_compile_definitions(usb PRIVATE "-DGUID_DEVINTERFACE_USB_DEVICE=(GUID){ 0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}}")
88 else() 115 else()
116 target_include_directories(usb
117 # turns out other projects also have "config.h", so make sure the
118 # LibUSB one comes first
119 BEFORE
120
121 PUBLIC
122 libusb/libusb
123
124 PRIVATE
125 "${CMAKE_CURRENT_BINARY_DIR}"
126 )
127 endif()
128
129 if(WIN32 OR CYGWIN)
130 target_sources(usb PRIVATE
131 libusb/libusb/os/threads_windows.c
132 libusb/libusb/os/windows_winusb.c
133 libusb/libusb/os/windows_usbdk.c
134 libusb/libusb/os/windows_common.c
135 )
136 set(OS_WINDOWS TRUE)
137 elseif(APPLE)
138 target_sources(usb PRIVATE
139 libusb/libusb/os/darwin_usb.c
140 )
141 find_library(COREFOUNDATION_LIBRARY CoreFoundation)
142 find_library(IOKIT_LIBRARY IOKit)
143 find_library(OBJC_LIBRARY objc)
144 target_link_libraries(usb PRIVATE
145 ${COREFOUNDATION_LIBRARY}
146 ${IOKIT_LIBRARY}
147 ${OBJC_LIBRARY}
148 )
149 set(OS_DARWIN TRUE)
150 elseif(ANDROID)
89 target_sources(usb PRIVATE 151 target_sources(usb PRIVATE
152 libusb/libusb/os/linux_usbfs.c
90 libusb/libusb/os/linux_netlink.c 153 libusb/libusb/os/linux_netlink.c
91 ) 154 )
155 find_library(LOG_LIBRARY log)
156 target_link_libraries(usb PRIVATE ${LOG_LIBRARY})
157 set(OS_LINUX TRUE)
158 elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
159 target_sources(usb PRIVATE
160 libusb/libusb/os/linux_usbfs.c
161 )
162 find_package(Libudev)
163 if(LIBUDEV_FOUND)
164 target_sources(usb PRIVATE
165 libusb/libusb/os/linux_udev.c
166 )
167 target_link_libraries(usb PRIVATE "${LIBUDEV_LIBRARIES}")
168 target_include_directories(usb PRIVATE "${LIBUDEV_INCLUDE_DIR}")
169 set(HAVE_LIBUDEV TRUE)
170 set(USE_UDEV TRUE)
171 else()
172 target_sources(usb PRIVATE
173 libusb/libusb/os/linux_netlink.c
174 )
175 endif()
176 set(OS_LINUX TRUE)
177 elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
178 target_sources(usb PRIVATE
179 libusb/libusb/os/netbsd_usb.c
180 )
181 set(OS_NETBSD TRUE)
182 elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
183 target_sources(usb PRIVATE
184 libusb/libusb/os/openbsd_usb.c
185 )
186 set(OS_OPENBSD TRUE)
92 endif() 187 endif()
93 set(OS_LINUX TRUE)
94elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
95 target_sources(usb PRIVATE
96 libusb/libusb/os/netbsd_usb.c
97 )
98 set(OS_NETBSD TRUE)
99elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
100 target_sources(usb PRIVATE
101 libusb/libusb/os/openbsd_usb.c
102 )
103 set(OS_OPENBSD TRUE)
104endif()
105 188
106if(UNIX) 189 if(UNIX)
107 target_sources(usb PRIVATE 190 target_sources(usb PRIVATE
108 libusb/libusb/os/events_posix.c 191 libusb/libusb/os/events_posix.c
109 libusb/libusb/os/threads_posix.c 192 libusb/libusb/os/threads_posix.c
110 ) 193 )
111 find_package(Threads REQUIRED) 194 find_package(Threads REQUIRED)
112 if(THREADS_HAVE_PTHREAD_ARG) 195 if(THREADS_HAVE_PTHREAD_ARG)
113 target_compile_options(usb PUBLIC "-pthread") 196 target_compile_options(usb PUBLIC "-pthread")
197 endif()
198 if(CMAKE_THREAD_LIBS_INIT)
199 target_link_libraries(usb PRIVATE "${CMAKE_THREAD_LIBS_INIT}")
200 endif()
201 set(THREADS_POSIX TRUE)
202 elseif(WIN32)
203 target_sources(usb PRIVATE
204 libusb/libusb/os/events_windows.c
205 libusb/libusb/os/threads_windows.c
206 )
114 endif() 207 endif()
115 if(CMAKE_THREAD_LIBS_INIT) 208
116 target_link_libraries(usb PRIVATE "${CMAKE_THREAD_LIBS_INIT}") 209 include(CheckFunctionExists)
210 include(CheckIncludeFiles)
211 include(CheckTypeSize)
212 check_include_files(asm/types.h HAVE_ASM_TYPES_H)
213 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
214 check_include_files(linux/filter.h HAVE_LINUX_FILTER_H)
215 check_include_files(linux/netlink.h HAVE_LINUX_NETLINK_H)
216 check_include_files(poll.h HAVE_POLL_H)
217 check_include_files(signal.h HAVE_SIGNAL_H)
218 check_include_files(strings.h HAVE_STRINGS_H)
219 check_type_size("struct timespec" STRUCT_TIMESPEC)
220 check_function_exists(syslog HAVE_SYSLOG_FUNC)
221 check_include_files(syslog.h HAVE_SYSLOG_H)
222 check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
223 check_include_files(sys/time.h HAVE_SYS_TIME_H)
224 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
225
226 set(CMAKE_EXTRA_INCLUDE_FILES poll.h)
227 check_type_size("nfds_t" nfds_t)
228 unset(CMAKE_EXTRA_INCLUDE_FILES)
229 if(HAVE_NFDS_T)
230 set(POLL_NFDS_TYPE "nfds_t")
231 else()
232 set(POLL_NFDS_TYPE "unsigned int")
117 endif() 233 endif()
118 set(THREADS_POSIX TRUE) 234
119elseif(WIN32) 235 check_include_files(sys/timerfd.h USBI_TIMERFD_AVAILABLE)
120 target_sources(usb PRIVATE 236
121 libusb/libusb/os/events_windows.c 237
122 libusb/libusb/os/threads_windows.c 238 configure_file(config.h.in config.h)
123 ) 239endif() # MINGW
124endif()
125
126include(CheckFunctionExists)
127include(CheckIncludeFiles)
128include(CheckTypeSize)
129check_include_files(asm/types.h HAVE_ASM_TYPES_H)
130check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
131check_include_files(linux/filter.h HAVE_LINUX_FILTER_H)
132check_include_files(linux/netlink.h HAVE_LINUX_NETLINK_H)
133check_include_files(poll.h HAVE_POLL_H)
134check_include_files(signal.h HAVE_SIGNAL_H)
135check_include_files(strings.h HAVE_STRINGS_H)
136check_type_size("struct timespec" STRUCT_TIMESPEC)
137check_function_exists(syslog HAVE_SYSLOG_FUNC)
138check_include_files(syslog.h HAVE_SYSLOG_H)
139check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
140check_include_files(sys/time.h HAVE_SYS_TIME_H)
141check_include_files(sys/types.h HAVE_SYS_TYPES_H)
142
143set(CMAKE_EXTRA_INCLUDE_FILES poll.h)
144check_type_size("nfds_t" nfds_t)
145unset(CMAKE_EXTRA_INCLUDE_FILES)
146if(HAVE_NFDS_T)
147 set(POLL_NFDS_TYPE "nfds_t")
148else()
149 set(POLL_NFDS_TYPE "unsigned int")
150endif()
151
152check_include_files(sys/timerfd.h USBI_TIMERFD_AVAILABLE)
153
154
155configure_file(config.h.in config.h)