summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt12
-rw-r--r--externals/libusb/CMakeLists.txt44
2 files changed, 37 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba207dfd1..c07be6f57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,8 @@ option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
23 23
24option(YUZU_USE_BUNDLED_BOOST "Download bundled Boost" OFF) 24option(YUZU_USE_BUNDLED_BOOST "Download bundled Boost" OFF)
25 25
26option(YUZU_USE_BUNDLED_LIBUSB "Compile bundled libusb" OFF)
27
26CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" ON "WIN32" OFF) 28CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" ON "WIN32" OFF)
27 29
28option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) 30option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF)
@@ -422,11 +424,15 @@ endif()
422# Ensure libusb is properly configured (based on dolphin libusb include) 424# Ensure libusb is properly configured (based on dolphin libusb include)
423if(NOT APPLE) 425if(NOT APPLE)
424 include(FindPkgConfig) 426 include(FindPkgConfig)
425 find_package(LibUSB) 427 if (PKG_CONFIG_FOUND)
428 pkg_check_modules(LIBUSB QUIET libusb-1.0>=1.0.24)
429 else()
430 find_package(LibUSB)
431 endif()
426endif() 432endif()
427if (NOT LIBUSB_FOUND) 433if (NOT LIBUSB_FOUND OR YUZU_USE_BUNDLED_LIBUSB)
428 add_subdirectory(externals/libusb) 434 add_subdirectory(externals/libusb)
429 set(LIBUSB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/externals/libusb/libusb/libusb") 435 set(LIBUSB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/libusb/libusb/libusb")
430 set(LIBUSB_LIBRARIES usb) 436 set(LIBUSB_LIBRARIES usb)
431endif() 437endif()
432 438
diff --git a/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt
index 3ef007b40..da6d68684 100644
--- a/externals/libusb/CMakeLists.txt
+++ b/externals/libusb/CMakeLists.txt
@@ -1,10 +1,10 @@
1if (MINGW) 1if (MINGW OR NOT WIN32)
2 # The MinGW toolchain for some reason doesn't work with this CMakeLists file after updating to 2 # GNU toolchains for some reason doesn't work with the later half of this CMakeLists after
3 # 1.0.24, so we do it the old-fashioned way for now. We may want to move native Linux toolchains 3 # updating to 1.0.24, so we do it the old-fashioned way for now.
4 # to here, too (TODO lat9nq?).
5 4
6 set(LIBUSB_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libusb") 5 set(LIBUSB_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libusb")
7 set(LIBUSB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libusb") 6 set(LIBUSB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libusb")
7
8 # Workarounds for MSYS/MinGW 8 # Workarounds for MSYS/MinGW
9 if (MSYS) 9 if (MSYS)
10 # CMake on Windows passes `C:/`, but we need `/C/` or `/c/` to use `configure` 10 # CMake on Windows passes `C:/`, but we need `/C/` or `/c/` to use `configure`
@@ -19,9 +19,18 @@ if (MINGW)
19 19
20 set(LIBUSB_CONFIGURE "${LIBUSB_SRC_DIR}/configure") 20 set(LIBUSB_CONFIGURE "${LIBUSB_SRC_DIR}/configure")
21 set(LIBUSB_MAKEFILE "${LIBUSB_PREFIX}/Makefile") 21 set(LIBUSB_MAKEFILE "${LIBUSB_PREFIX}/Makefile")
22 set(LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll.a") 22
23 set(LIBUSB_SHARED_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll") 23 if (MINGW)
24 set(LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.dll") 24 set(LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll.a")
25 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")
27
28 set(LIBUSB_CONFIGURE_ARGS --host=x86_64-w64-mingw32 --build=x86_64-windows)
29 else()
30 set(LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.so")
31 set(LIBUSB_SHARED_LIBRARY "${LIBUSB_LIBRARY}")
32 set(LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.so")
33 endif()
25 34
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. 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.
27 # set(LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}") 36 # set(LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}")
@@ -37,11 +46,6 @@ if (MINGW)
37 "${LIBUSB_PREFIX}" 46 "${LIBUSB_PREFIX}"
38 ) 47 )
39 48
40 # We may use this path for other GNU toolchains, so put all of the MinGW-specific stuff here
41 if (MINGW)
42 set(LIBUSB_CONFIGURE_ARGS --host=x86_64-w64-mingw32 --build=x86_64-windows)
43 endif()
44
45 add_custom_command( 49 add_custom_command(
46 OUTPUT 50 OUTPUT
47 "${LIBUSB_MAKEFILE}" 51 "${LIBUSB_MAKEFILE}"
@@ -71,16 +75,24 @@ if (MINGW)
71 /bin/cp "${LIBUSB_SHARED_LIBRARY}" "${LIBUSB_SHARED_LIBRARY_DEST}" 75 /bin/cp "${LIBUSB_SHARED_LIBRARY}" "${LIBUSB_SHARED_LIBRARY_DEST}"
72 ) 76 )
73 77
74 add_custom_target(usb-bootstrap ALL DEPENDS "${LIBUSB_CONFIGURE}") 78 add_custom_target(usb-bootstrap DEPENDS "${LIBUSB_CONFIGURE}")
75 add_custom_target(usb-configure ALL DEPENDS "${LIBUSB_MAKEFILE}" usb-bootstrap) 79 add_custom_target(usb-configure DEPENDS "${LIBUSB_MAKEFILE}" usb-bootstrap)
76 add_custom_target(usb-build ALL DEPENDS "${LIBUSB_LIBRARY}" usb-configure) 80 add_custom_target(usb-build ALL DEPENDS "${LIBUSB_LIBRARY}" usb-configure)
77 # Workaround since static linking didn't work out -- We need to copy the DLL to the bin directory 81 # Workaround since static linking didn't work out -- We need to copy the DLL to the bin directory
78 add_custom_target(usb-copy ALL DEPENDS "${LIBUSB_SHARED_LIBRARY_DEST}" usb-build) 82 add_custom_target(usb-copy ALL DEPENDS "${LIBUSB_SHARED_LIBRARY_DEST}" usb-build)
79 83
80 # Make `usb` alias to LIBUSB_LIBRARY
81 add_library(usb INTERFACE) 84 add_library(usb INTERFACE)
85 add_dependencies(usb usb-copy)
82 target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARY}") 86 target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARY}")
83else() # MINGW 87
88 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
89 find_package(Libudev QUIET)
90 if(LIBUDEV_FOUND)
91 target_link_libraries(usb INTERFACE "${LIBUDEV_LIBRARIES}")
92 target_include_directories(usb INTERFACE "${LIBUDEV_INCLUDE_DIR}")
93 endif()
94 endif()
95else() # MINGW OR NOT WIN32
84 # Ensure libusb compiles with UTF-8 encoding on MSVC 96 # Ensure libusb compiles with UTF-8 encoding on MSVC
85 if(MSVC) 97 if(MSVC)
86 add_compile_options(/utf-8) 98 add_compile_options(/utf-8)