diff options
| author | 2021-06-03 03:49:35 -0400 | |
|---|---|---|
| committer | 2021-06-03 03:49:35 -0400 | |
| commit | ddc47e6df8cd9e06d799933f67e75ba6f8952acd (patch) | |
| tree | f1fd486d62f031cc4606c42dab2fea60d3af5fd2 /externals/libusb | |
| parent | cmake: Use autotools to build libusb generally for GNU (diff) | |
| download | yuzu-ddc47e6df8cd9e06d799933f67e75ba6f8952acd.tar.gz yuzu-ddc47e6df8cd9e06d799933f67e75ba6f8952acd.tar.xz yuzu-ddc47e6df8cd9e06d799933f67e75ba6f8952acd.zip | |
cmake: General improvements to libusb linking
Delegates libusb external communication to externals/CMakeLists.txt
Ensures an interface library `usb` for every pathway
input_common just links to the `usb` library now
externals/libusb/CMakeLists.txt sets variables to override SDL2's libusb
finding
Other minor cleanup
Diffstat (limited to 'externals/libusb')
| -rw-r--r-- | externals/libusb/CMakeLists.txt | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt index da6d68684..b2b36261c 100644 --- a/externals/libusb/CMakeLists.txt +++ b/externals/libusb/CMakeLists.txt | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | if (MINGW OR NOT WIN32) | 1 | set(LIBUSB_FOUND ON CACHE BOOL "libusb is present" FORCE) |
| 2 | set(LIBUSB_VERSION "1.0.24" CACHE STRING "libusb version string" FORCE) | ||
| 3 | |||
| 4 | if (MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux")) | ||
| 2 | # GNU toolchains for some reason doesn't work with the later half of this CMakeLists after | 5 | # GNU toolchains for some reason doesn't work with the later half of this CMakeLists after |
| 3 | # updating to 1.0.24, so we do it the old-fashioned way for now. | 6 | # updating to 1.0.24, so we do it the old-fashioned way for now. |
| 4 | 7 | ||
| @@ -21,17 +24,19 @@ if (MINGW OR NOT WIN32) | |||
| 21 | set(LIBUSB_MAKEFILE "${LIBUSB_PREFIX}/Makefile") | 24 | set(LIBUSB_MAKEFILE "${LIBUSB_PREFIX}/Makefile") |
| 22 | 25 | ||
| 23 | if (MINGW) | 26 | if (MINGW) |
| 24 | set(LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll.a") | 27 | set(LIBUSB_LIBRARIES "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll.a" CACHE PATH "libusb library path" FORCE) |
| 25 | set(LIBUSB_SHARED_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll") | 28 | set(LIBUSB_SHARED_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll") |
| 26 | set(LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.dll") | 29 | set(LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.dll") |
| 27 | 30 | ||
| 28 | set(LIBUSB_CONFIGURE_ARGS --host=x86_64-w64-mingw32 --build=x86_64-windows) | 31 | set(LIBUSB_CONFIGURE_ARGS --host=x86_64-w64-mingw32 --build=x86_64-windows) |
| 29 | else() | 32 | else() |
| 30 | set(LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.so") | 33 | set(LIBUSB_LIBRARIES "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.so" CACHE PATH "libusb library path" FORCE) |
| 31 | set(LIBUSB_SHARED_LIBRARY "${LIBUSB_LIBRARY}") | 34 | set(LIBUSB_SHARED_LIBRARY "${LIBUSB_LIBRARIES}") |
| 32 | set(LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.so") | 35 | set(LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.so") |
| 33 | endif() | 36 | endif() |
| 34 | 37 | ||
| 38 | set(LIBUSB_INCLUDE_DIRS "${LIBUSB_SRC_DIR}/libusb" CACHE PATH "libusb headers path" FORCE) | ||
| 39 | |||
| 35 | # 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. | 40 | # 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. |
| 36 | # set(LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}") | 41 | # set(LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}") |
| 37 | 42 | ||
| @@ -39,7 +44,7 @@ if (MINGW OR NOT WIN32) | |||
| 39 | 44 | ||
| 40 | add_custom_command( | 45 | add_custom_command( |
| 41 | OUTPUT | 46 | OUTPUT |
| 42 | "${LIBUSB_LIBRARY}" | 47 | "${LIBUSB_LIBRARIES}" |
| 43 | COMMAND | 48 | COMMAND |
| 44 | make | 49 | make |
| 45 | WORKING_DIRECTORY | 50 | WORKING_DIRECTORY |
| @@ -77,13 +82,14 @@ if (MINGW OR NOT WIN32) | |||
| 77 | 82 | ||
| 78 | add_custom_target(usb-bootstrap DEPENDS "${LIBUSB_CONFIGURE}") | 83 | add_custom_target(usb-bootstrap DEPENDS "${LIBUSB_CONFIGURE}") |
| 79 | add_custom_target(usb-configure DEPENDS "${LIBUSB_MAKEFILE}" usb-bootstrap) | 84 | add_custom_target(usb-configure DEPENDS "${LIBUSB_MAKEFILE}" usb-bootstrap) |
| 80 | add_custom_target(usb-build ALL DEPENDS "${LIBUSB_LIBRARY}" usb-configure) | 85 | add_custom_target(usb-build ALL DEPENDS "${LIBUSB_LIBRARIES}" usb-configure) |
| 81 | # Workaround since static linking didn't work out -- We need to copy the DLL to the bin directory | 86 | # Workaround since static linking didn't work out -- We need to copy the DLL to the bin directory |
| 82 | add_custom_target(usb-copy ALL DEPENDS "${LIBUSB_SHARED_LIBRARY_DEST}" usb-build) | 87 | add_custom_target(usb-copy ALL DEPENDS "${LIBUSB_SHARED_LIBRARY_DEST}" usb-build) |
| 83 | 88 | ||
| 84 | add_library(usb INTERFACE) | 89 | add_library(usb INTERFACE) |
| 85 | add_dependencies(usb usb-copy) | 90 | add_dependencies(usb usb-copy) |
| 86 | target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARY}") | 91 | target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARIES}") |
| 92 | target_include_directories(usb INTERFACE "${LIBUSB_INCLUDE_DIRS}") | ||
| 87 | 93 | ||
| 88 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") | 94 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 89 | find_package(Libudev QUIET) | 95 | find_package(Libudev QUIET) |
| @@ -92,7 +98,7 @@ if (MINGW OR NOT WIN32) | |||
| 92 | target_include_directories(usb INTERFACE "${LIBUDEV_INCLUDE_DIR}") | 98 | target_include_directories(usb INTERFACE "${LIBUDEV_INCLUDE_DIR}") |
| 93 | endif() | 99 | endif() |
| 94 | endif() | 100 | endif() |
| 95 | else() # MINGW OR NOT WIN32 | 101 | else() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 96 | # Ensure libusb compiles with UTF-8 encoding on MSVC | 102 | # Ensure libusb compiles with UTF-8 encoding on MSVC |
| 97 | if(MSVC) | 103 | if(MSVC) |
| 98 | add_compile_options(/utf-8) | 104 | add_compile_options(/utf-8) |
| @@ -248,4 +254,4 @@ else() # MINGW OR NOT WIN32 | |||
| 248 | 254 | ||
| 249 | 255 | ||
| 250 | configure_file(config.h.in config.h) | 256 | configure_file(config.h.in config.h) |
| 251 | endif() # MINGW | 257 | endif() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |