From 7cea3a47c9c52f735d7c652680a4ab379fa75a4f Mon Sep 17 00:00:00 2001 From: Adrien Bertrand Date: Mon, 16 Jan 2023 12:10:10 +0100 Subject: [PATCH] windows: let's just try libusb-1.0 for now, instead of libusb-win32 --- libticables/trunk/CMakeLists.txt | 6 ++++++ libticables/trunk/src/link_usb.cc | 2 +- libticables/trunk/src/ticables.cc | 8 ++++---- libticables/trunk/src/win32/detect.cc | 6 +++++- libticables/trunk/tests/CMakeLists.txt | 6 ++++++ libticalcs/trunk/tests/CMakeLists.txt | 6 ++++++ vcpkg.json | 2 +- 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libticables/trunk/CMakeLists.txt b/libticables/trunk/CMakeLists.txt index ee5936aca..85c8da87a 100644 --- a/libticables/trunk/CMakeLists.txt +++ b/libticables/trunk/CMakeLists.txt @@ -45,6 +45,12 @@ endif() # external deps lookup pkg_check_modules(DEPS REQUIRED glib-2.0 libusb-1.0>=1.0.16) +if(WIN32) + # Actually, the lib files are called libusb-1.0.ext, with the prefix (not usb-1.0.ext) + list(REMOVE_ITEM DEPS_LIBRARIES "usb-1.0") + list(APPEND DEPS_LIBRARIES "libusb-1.0") + list(REMOVE_DUPLICATES DEPS_LIBRARIES) # just in case +endif() try_static_libs_if_needed() diff --git a/libticables/trunk/src/link_usb.cc b/libticables/trunk/src/link_usb.cc index 6ea82a053..dedbba492 100644 --- a/libticables/trunk/src/link_usb.cc +++ b/libticables/trunk/src/link_usb.cc @@ -27,7 +27,7 @@ #ifndef NO_CABLE_SLV -#if defined(__WIN32__) && !defined(__MINGW32__) +#if !defined(HAVE_LIBUSB_1_0) && defined(__WIN32__) && !defined(__MINGW32__) # define HAVE_LIBUSB #endif diff --git a/libticables/trunk/src/ticables.cc b/libticables/trunk/src/ticables.cc index a6da9faca..5f1837230 100644 --- a/libticables/trunk/src/ticables.cc +++ b/libticables/trunk/src/ticables.cc @@ -35,12 +35,12 @@ #include #endif -#ifdef _MSC_VER -# include "./win32/usb.h" +#if defined(HAVE_LIBUSB_1_0) +# include #elif defined(HAVE_LIBUSB) # include -#elif defined(HAVE_LIBUSB_1_0) -# include +#elif defined(_MSC_VER) +# include "./win32/usb.h" #endif #include "gettext.h" diff --git a/libticables/trunk/src/win32/detect.cc b/libticables/trunk/src/win32/detect.cc index 64f5671fb..6733c534d 100644 --- a/libticables/trunk/src/win32/detect.cc +++ b/libticables/trunk/src/win32/detect.cc @@ -91,8 +91,12 @@ int win32_check_rwp(void) int win32_check_libusb(void) { - if(usb_get_version() != NULL) +#ifdef HAVE_LIBUSB_1_0 + return 0; +#else + if (usb_get_version() != NULL) return 0; else return ERR_LIBUSBWIN32_NOT_PRESENT; +#endif // HAVE_LIBUSB_1_0 } diff --git a/libticables/trunk/tests/CMakeLists.txt b/libticables/trunk/tests/CMakeLists.txt index 49ff7dc5e..2bf1df4c4 100644 --- a/libticables/trunk/tests/CMakeLists.txt +++ b/libticables/trunk/tests/CMakeLists.txt @@ -7,6 +7,12 @@ add_executable(torture_ticables torture_ticables.c) add_executable(test_ticables_2 test_ticables_2.cc) pkg_check_modules(DEPS REQUIRED glib-2.0 libusb-1.0>=1.0.16) +if(WIN32) + # Actually, the lib files are called libusb-1.0.ext, with the prefix (not usb-1.0.ext) + list(REMOVE_ITEM DEPS_LIBRARIES "usb-1.0") + list(APPEND DEPS_LIBRARIES "libusb-1.0") + list(REMOVE_DUPLICATES DEPS_LIBRARIES) # just in case +endif() foreach(tar torture_ticables test_ticables_2) target_compile_options(${tar} PRIVATE ${DEPS_CFLAGS}) diff --git a/libticalcs/trunk/tests/CMakeLists.txt b/libticalcs/trunk/tests/CMakeLists.txt index 113df834f..0ed7cd115 100644 --- a/libticalcs/trunk/tests/CMakeLists.txt +++ b/libticalcs/trunk/tests/CMakeLists.txt @@ -7,6 +7,12 @@ add_executable(torture_ticalcs torture_ticalcs.c) add_executable(test_ticalcs_2 test_ticalcs_2.cc) pkg_check_modules(DEPS REQUIRED glib-2.0 libusb-1.0>=1.0.16 libarchive zlib) +if(WIN32) + # Actually, the lib files are called libusb-1.0.ext, with the prefix (not usb-1.0.ext) + list(REMOVE_ITEM DEPS_LIBRARIES "usb-1.0") + list(APPEND DEPS_LIBRARIES "libusb-1.0") + list(REMOVE_DUPLICATES DEPS_LIBRARIES) # just in case +endif() foreach(tar torture_ticalcs test_ticalcs_2) target_compile_options(${tar} PRIVATE ${DEPS_CFLAGS}) diff --git a/vcpkg.json b/vcpkg.json index 100f82d82..920db4d07 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -9,7 +9,7 @@ "name": "libarchive", "default-features": false }, - "libusb-win32", + "libusb", "glib", "gettext" ],