Skip to content

Commit

Permalink
[libusb] Fix usage (#35498)
Browse files Browse the repository at this point in the history
* fix usage

* update version

* redo x64-windows.cmake

* resolve conflicts

* updaet git-tree

* fix downstream

* update version

* fix libirecovery

* update git-tree

* fix pkg_check_modules

* update git-tree

* fix libfreenect2

* update version

* fix libuvc

* update version

* fix libuvc patch

* update git-tree

* fix libuvc build_fix.patch

* update git-tree

* format

* update git-tree

* undo supports

* update git-tree

* fix azure-kinect-sensor-sdk

* update version

* add pkg-config.exe

* update git-tree

* disable build examples and tests

* update git-tree

---------

Co-authored-by: Monica <v-liumonica@microsoft.com>
  • Loading branch information
MonicaLiu0311 and Monica committed Dec 14, 2023
1 parent 7d10d3d commit 8abeb71
Show file tree
Hide file tree
Showing 31 changed files with 181 additions and 85 deletions.
17 changes: 8 additions & 9 deletions ports/azure-kinect-sensor-sdk/fix-builds.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f002b5..d48f3f2 100644
index 4f002b5..dd9b1df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,8 +27,6 @@ option(K4A_BUILD_DOCS "Build K4A doxygen documentation" OFF)
Expand All @@ -11,7 +11,7 @@ index 4f002b5..d48f3f2 100644
# Set the project version
include(K4AProjectVersion)

@@ -100,6 +98,43 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL
@@ -100,6 +98,42 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()

Expand All @@ -34,14 +34,13 @@ index 4f002b5..d48f3f2 100644
+add_definitions(-DMATROSKA_VERSION=2)
+find_package(libsoundio CONFIG REQUIRED)
+if (NOT WIN32)
+ find_package(libusb CONFIG REQUIRED)
+ find_package(libuvc CONFIG REQUIRED)
+ add_library(libuvc::libuvc ALIAS LibUVC::UVCStatic)
+ find_package(OpenSSL REQUIRED)
+ find_package(ZLIB REQUIRED)
+else()
+ find_library(LibUSB libusb-1.0 REQUIRED)
+endif()
+FIND_PACKAGE(PkgConfig REQUIRED)
+pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
+find_package(libyuv CONFIG REQUIRED)
+find_package(spdlog CONFIG REQUIRED)
+if (BUILD_TOOLS)
Expand Down Expand Up @@ -295,7 +294,7 @@ index e4a696e..6ee6696 100644
k4ainternal::deloader)

diff --git a/src/usbcommand/CMakeLists.txt b/src/usbcommand/CMakeLists.txt
index f75bd55..5403216 100644
index f75bd55..7130728 100644
--- a/src/usbcommand/CMakeLists.txt
+++ b/src/usbcommand/CMakeLists.txt
@@ -12,8 +12,8 @@ target_include_directories(k4a_usb_cmd PUBLIC
Expand All @@ -305,7 +304,7 @@ index f75bd55..5403216 100644
- azure::aziotsharedutil
- LibUSB::LibUSB
+ aziotsharedutil
+ ${LibUSB}
+ PkgConfig::libusb
k4ainternal::allocator
k4ainternal::image
k4ainternal::logging)
Expand Down Expand Up @@ -585,7 +584,7 @@ index c544e1e..9489bf8 100644
k4ainternal::logging
k4ainternal::utcommon)
diff --git a/tools/k4aviewer/CMakeLists.txt b/tools/k4aviewer/CMakeLists.txt
index 98578c0..6ab38d9 100644
index 98578c0..244c867 100644
--- a/tools/k4aviewer/CMakeLists.txt
+++ b/tools/k4aviewer/CMakeLists.txt
@@ -60,10 +60,11 @@ set(EXTERNAL_LIBRARIES
Expand All @@ -595,7 +594,7 @@ index 98578c0..6ab38d9 100644
- LibUSB::LibUSB
- libyuv::libyuv
- glfw::glfw
+ ${LibUSB}
+ PkgConfig::libusb
+ yuv
+ glfw
${OPENGL_LIBRARIES}
Expand Down
9 changes: 6 additions & 3 deletions ports/azure-kinect-sensor-sdk/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(VERSION 1.4.1)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO microsoft/Azure-Kinect-Sensor-SDK
REF v${VERSION}
REF "v${VERSION}"
SHA512 ef94c072caae43b0a105b192013e09082d267d4064e6676fac981b52e7576a663f59fcb53f0afe66b425ef2cea0cb3aa224ff7be6485c0b5543ff9cdabd82d4d
HEAD_REF master
PATCHES
Expand All @@ -14,6 +14,7 @@ vcpkg_from_github(
)

vcpkg_find_acquire_program(PYTHON3)
vcpkg_find_acquire_program(PKGCONFIG)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")

Expand All @@ -27,7 +28,9 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS ${FEATURE_OPTIONS}
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
${FEATURE_OPTIONS}
-DK4A_SOURCE_LINK=OFF
-DK4A_MTE_VERSION=ON
-DBUILD_EXAMPLES=OFF
Expand Down Expand Up @@ -88,4 +91,4 @@ else()
endif()

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
2 changes: 1 addition & 1 deletion ports/azure-kinect-sensor-sdk/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "azure-kinect-sensor-sdk",
"version": "1.4.1",
"port-version": 5,
"port-version": 6,
"description": "Azure Kinect SDK is a cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device.",
"homepage": "https://github.com/microsoft/Azure-Kinect-Sensor-SDK",
"supports": "linux | windows",
Expand Down
3 changes: 3 additions & 0 deletions ports/dv-processing/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ vcpkg_check_features(
tools ENABLE_UTILITIES
)

vcpkg_find_acquire_program(PKGCONFIG)

set(VCPKG_BUILD_TYPE release) # no lib binaries
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE # writes to include/dv-processing/version.hpp
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
${FEATURE_OPTIONS}
"-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake"
-DCMAKE_DISABLE_FIND_PACKAGE_Git=ON
Expand Down
1 change: 1 addition & 0 deletions ports/dv-processing/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "dv-processing",
"version": "1.7.9",
"port-version": 1,
"description": "Generic algorithms for event cameras. (C++20 required.)",
"homepage": "https://gitlab.com/inivation/dv/dv-processing",
"license": "Apache-2.0",
Expand Down
57 changes: 51 additions & 6 deletions ports/libcaer/fix-libusb.diff
Original file line number Diff line number Diff line change
@@ -1,17 +1,62 @@
diff --git a/cmakemod/libcaerConfig.cmake.in b/cmakemod/libcaerConfig.cmake.in
index cdf9f88..475d543 100644
index cdf9f88..f0a17ba 100644
--- a/cmakemod/libcaerConfig.cmake.in
+++ b/cmakemod/libcaerConfig.cmake.in
@@ -21,6 +21,12 @@
@@ -21,6 +21,10 @@
CMAKE_POLICY(PUSH)
CMAKE_POLICY(VERSION 3.10)

+include(CMakeFindDependencyMacro)
+if(NOT "@CC_MSVC@")
+ find_dependency(PkgConfig)
+ pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
+endif()
+find_dependency(PkgConfig)
+pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
+
INCLUDE(@PACKAGE_export_destination@/libcaer-exports.cmake)
SET(libcaer_INCLUDE_DIRS @PACKAGE_include_dirs@)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ce94a6..f03d7ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,16 +52,12 @@ MESSAGE(STATUS "Base libraries: ${BASE_LIBS}")
INCLUDE(FindPkgConfig)

# Required: basic USB devices support
-IF(CC_MSVC)
- FIND_PACKAGE(libusb CONFIG REQUIRED)
-ELSE()
- PKG_CHECK_MODULES(
- libusb
- REQUIRED
- IMPORTED_TARGET
- libusb-1.0>=1.0.17)
- SET(LIBCAER_PKGCONFIG_REQUIRES_PRIVATE "libusb-1.0 >= 1.0.17")
-ENDIF()
+PKG_CHECK_MODULES(
+ libusb
+ REQUIRED
+ IMPORTED_TARGET
+ libusb-1.0>=1.0.17)
+SET(LIBCAER_PKGCONFIG_REQUIRES_PRIVATE "libusb-1.0 >= 1.0.17")

# Optional: serial devices support
IF(ENABLE_SERIALDEV)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0ef4ac7..6f70a26 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -49,12 +49,11 @@ ENDIF()

IF(CC_MSVC)
LIST(APPEND LIBCAER_SOURCES ../thirdparty/simple-stdatomic/stdatomic.c)
- INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS})
- LIST(APPEND LIBCAER_LINK_LIBRARIES_PRIVATE ${LIBUSB_LIBRARIES})
-ELSE()
- LIST(APPEND LIBCAER_LINK_LIBRARIES_PRIVATE PkgConfig::libusb)
ENDIF()

+LIST(APPEND LIBCAER_LINK_LIBRARIES_PRIVATE PkgConfig::libusb)
+
+
# Set full RPATH
SET(CMAKE_INSTALL_RPATH ${USER_LOCAL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

1 change: 1 addition & 0 deletions ports/libcaer/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "libcaer",
"version": "3.3.15",
"port-version": 1,
"description": "Minimal C library to access, configure and get data from neuromorphic sensors and processors.",
"homepage": "https://gitlab.com/inivation/dv/libcaer",
"license": "BSD-2-Clause AND Apache-2.0",
Expand Down
14 changes: 7 additions & 7 deletions ports/libfreenect2/fix-dependency-libusb.patch
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e0d192..aedc576 100644
index 3648fb5..43c3d28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,7 +90,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
@@ -91,7 +91,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

# dependencies
FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found
-FIND_PACKAGE(LibUSB REQUIRED)
+FIND_PACKAGE(libusb CONFIG REQUIRED)
+pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)

# Add includes
INCLUDE_DIRECTORIES(
@@ -98,7 +98,7 @@ INCLUDE_DIRECTORIES(
@@ -99,7 +99,7 @@ INCLUDE_DIRECTORIES(
"${MY_DIR}/include/internal"
${PROJECT_BINARY_DIR} # for generated headers
${LIBFREENECT2_THREADING_INCLUDE_DIR}
- ${LibUSB_INCLUDE_DIRS}
+ ${LIBUSB_INCLUDE_DIRS}
+ ${libusb_INCLUDE_DIRS}
)

SET(RESOURCES_INC_FILE "${PROJECT_BINARY_DIR}/resources.inc.h")
@@ -154,7 +154,7 @@ SET(SOURCES
@@ -157,7 +157,7 @@ SET(SOURCES
)

SET(LIBRARIES
- ${LibUSB_LIBRARIES}
+ ${LIBUSB_LIBRARIES}
+ PkgConfig::libusb
${LIBFREENECT2_THREADING_LIBRARIES}
)

13 changes: 13 additions & 0 deletions ports/libfreenect2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,26 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
openni2 BUILD_OPENNI2_DRIVER
)

vcpkg_find_acquire_program(PKGCONFIG)

if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(path_suffix "/debug")
endif()
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
set(path_suffix "")
endif()
vcpkg_backup_env_variables(VARS PKG_CONFIG_PATH)
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${CURRENT_INSTALLED_DIR}${path_suffix}/lib/pkgconfig")

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
-DENABLE_CUDA=OFF
-DBUILD_EXAMPLES=OFF
${FEATURE_OPTIONS}
)
vcpkg_restore_env_variables(VARS PKG_CONFIG_PATH)

vcpkg_cmake_install()

Expand Down
1 change: 1 addition & 0 deletions ports/libfreenect2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "libfreenect2",
"version": "0.2.1",
"port-version": 1,
"description": "Open source drivers for the Kinect for Windows v2 device",
"homepage": "https://github.com/OpenKinect/libfreenect2",
"license": "GPL-2.0-only",
Expand Down
12 changes: 6 additions & 6 deletions ports/libirecovery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ target_link_libraries(libirecovery
unofficial::libimobiledevice-glue::libimobiledevice-glue
)
if(NOT WIN32 AND NOT APPLE)
find_package(libusb CONFIG REQUIRED)
target_include_directories(libirecovery PRIVATE ${LIBUSB_INCLUDE_DIRS})
target_link_libraries(libirecovery PRIVATE ${LIBUSB_LIBRARIES})
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
target_link_libraries(libirecovery PRIVATE PkgConfig::libusb)
endif()
set_target_properties(libirecovery PROPERTIES OUTPUT_NAME irecovery-1.0)

Expand Down Expand Up @@ -111,9 +111,9 @@ if(BUILD_TOOLS)
target_link_libraries(irecovery PRIVATE "-framework IOKit" "-framework CoreFoundation")
endif()
if(NOT WIN32 AND NOT APPLE)
find_package(libusb CONFIG REQUIRED)
target_include_directories(irecovery PRIVATE ${LIBUSB_INCLUDE_DIRS})
target_link_libraries(irecovery PRIVATE ${LIBUSB_LIBRARIES})
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
target_link_libraries(irecovery PRIVATE PkgConfig::libusb)
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(readline REQUIRED IMPORTED_TARGET readline)
Expand Down
4 changes: 4 additions & 0 deletions ports/libirecovery/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-c
file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake"
"include(CMakeFindDependencyMacro)
find_dependency(unofficial-libimobiledevice-glue CONFIG)
if(NOT WIN32 AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
endif()
${cmake_config}
")

Expand Down
2 changes: 1 addition & 1 deletion ports/libirecovery/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "libirecovery",
"version-date": "2023-05-13",
"port-version": 1,
"port-version": 2,
"description": "Library and utility to talk to iBoot/iBSS via USB on Mac OS X, Windows, and Linux",
"homepage": "https://libimobiledevice.org/",
"license": "LGPL-2.1-or-later",
Expand Down
6 changes: 4 additions & 2 deletions ports/libusb/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ else()
vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
OPTIONS ${MAKE_OPTIONS}
OPTIONS
${MAKE_OPTIONS}
"--enable-examples-build=no"
"--enable-tests-build=no"
)
vcpkg_install_make()
endif()

vcpkg_fixup_pkgconfig()

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
8 changes: 4 additions & 4 deletions ports/libusb/usage
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
libusb provides CMake targets:
libusb can be imported via CMake FindPkgConfig module:
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)

find_package(libusb CONFIG REQUIRED)
target_include_directories(main PRIVATE ${LIBUSB_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${LIBUSB_LIBRARIES})
target_link_libraries(main PRIVATE PkgConfig::libusb)
17 changes: 0 additions & 17 deletions ports/libusb/vcpkg-cmake-wrapper.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion ports/libusb/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "libusb",
"version": "1.0.26.11791",
"port-version": 5,
"port-version": 6,
"description": "a cross-platform library to access USB devices",
"homepage": "https://github.com/libusb/libusb",
"license": "LGPL-2.1-or-later",
Expand Down
Loading

0 comments on commit 8abeb71

Please sign in to comment.