From 55dd027115e72ca2ffc6a0bbf8f131d380c73faa Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 3 Jun 2021 02:49:53 -0400 Subject: cmake: Use autotools to build libusb generally for GNU Building libusb was also broken on GCC (and maybe Clang) on our CMakeLists after upgrading to 1.0.24, but it was not being checked because our 18.04 container had libusb installed on it. This builds on the MinGW work from earlier and extends it to the rest of the GNU toolchains. In addition we make use of pkg-config when present to find libusb. pkg-config is preferrable because we can specify a minimum required version. --- CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'CMakeLists.txt') 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) option(YUZU_USE_BUNDLED_BOOST "Download bundled Boost" OFF) +option(YUZU_USE_BUNDLED_LIBUSB "Compile bundled libusb" OFF) + CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" ON "WIN32" OFF) option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) @@ -422,11 +424,15 @@ endif() # Ensure libusb is properly configured (based on dolphin libusb include) if(NOT APPLE) include(FindPkgConfig) - find_package(LibUSB) + if (PKG_CONFIG_FOUND) + pkg_check_modules(LIBUSB QUIET libusb-1.0>=1.0.24) + else() + find_package(LibUSB) + endif() endif() -if (NOT LIBUSB_FOUND) +if (NOT LIBUSB_FOUND OR YUZU_USE_BUNDLED_LIBUSB) add_subdirectory(externals/libusb) - set(LIBUSB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/externals/libusb/libusb/libusb") + set(LIBUSB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/libusb/libusb/libusb") set(LIBUSB_LIBRARIES usb) endif() -- cgit v1.2.3 From ddc47e6df8cd9e06d799933f67e75ba6f8952acd Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 3 Jun 2021 03:49:35 -0400 Subject: 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 --- CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index c07be6f57..68d9e5f9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -422,18 +422,22 @@ elseif (TARGET Boost::boost) endif() # Ensure libusb is properly configured (based on dolphin libusb include) -if(NOT APPLE) +if(NOT APPLE AND NOT YUZU_USE_BUNDLED_LIBUSB) include(FindPkgConfig) if (PKG_CONFIG_FOUND) pkg_check_modules(LIBUSB QUIET libusb-1.0>=1.0.24) else() find_package(LibUSB) endif() -endif() -if (NOT LIBUSB_FOUND OR YUZU_USE_BUNDLED_LIBUSB) - add_subdirectory(externals/libusb) - set(LIBUSB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/libusb/libusb/libusb") - set(LIBUSB_LIBRARIES usb) + + if (NOT LIBUSB_FOUND) + message(WARNING "libusb not found, falling back to externals") + set(YUZU_USE_BUNDLED_LIBUSB ON) + else() + add_library(usb INTERFACE) + target_include_directories(usb INTERFACE "${LIBUSB_INCLUDE_DIRS}") + target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARIES}") + endif() endif() # List of all FFmpeg components required -- cgit v1.2.3 From 890acfa2c001a034e0a837404118b3670305e0df Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 3 Jun 2021 04:38:29 -0400 Subject: externals: libusb: Link libusb statically on Linux Turns out that this is possible. Also addresses my own review comment. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 68d9e5f9d..97afaf1a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -430,13 +430,13 @@ if(NOT APPLE AND NOT YUZU_USE_BUNDLED_LIBUSB) find_package(LibUSB) endif() - if (NOT LIBUSB_FOUND) - message(WARNING "libusb not found, falling back to externals") - set(YUZU_USE_BUNDLED_LIBUSB ON) - else() + if (LIBUSB_FOUND) add_library(usb INTERFACE) target_include_directories(usb INTERFACE "${LIBUSB_INCLUDE_DIRS}") target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARIES}") + else() + message(WARNING "libusb not found, falling back to externals") + set(YUZU_USE_BUNDLED_LIBUSB ON) endif() endif() -- cgit v1.2.3