Skip to content

Commit

Permalink
[libusb] Add vcpkg-cmake-wrapper (#13057)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackBoosY committed Aug 26, 2020
1 parent fd7e280 commit 0522f98
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ports/libfreenect2/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: libfreenect2
Version: 0.2.0-4
Version: 0.2.0
Port-Version: 5
Build-Depends: libusb, libjpeg-turbo
Homepage: https://github.com/OpenKinect/libfreenect2
Description: Open source drivers for the Kinect for Windows v2 device
Expand Down
31 changes: 31 additions & 0 deletions ports/libfreenect2/fix-dependency-libusb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e0d192..aedc576 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,7 +90,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)

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

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

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

13 changes: 3 additions & 10 deletions ports/libfreenect2/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
include(vcpkg_common_functions)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO OpenKinect/libfreenect2
REF v0.2.0
SHA512 3525e3f21462cecd3b198f64545786ffddc2cafdfd8146e5a46f0300b83f29f1ad0739618a07ab195c276149d7e2e909f7662e2d379a2880593cac75942b0666
HEAD_REF master
PATCHES fix-dependency-libusb.patch
)

file(READ ${SOURCE_PATH}/cmake_modules/FindLibUSB.cmake FINDLIBUSB)
Expand Down Expand Up @@ -34,16 +33,10 @@ vcpkg_configure_cmake(

vcpkg_install_cmake()

vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/freenect2)
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/freenect2 TARGET_PATH share/freenect2)

vcpkg_copy_pdbs()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

# The cmake config is actually called freenect2Config.cmake instead of libfreenect2Config.cmake ...
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libfreenect2 ${CURRENT_PACKAGES_DIR}/share/freenect2)

# license file needs to be in share/libfreenect2 otherwise vcpkg will complain
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/libfreenect2/)
file(COPY ${SOURCE_PATH}/GPL2 DESTINATION ${CURRENT_PACKAGES_DIR}/share/libfreenect2/)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libfreenect2/GPL2 ${CURRENT_PACKAGES_DIR}/share/libfreenect2/copyright)
file(INSTALL ${SOURCE_PATH}/GPL2 DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
2 changes: 1 addition & 1 deletion ports/libusb/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: libusb
Version: 1.0.23
Port-Version: 2
Port-Version: 3
Homepage: https://github.com/libusb/libusb
Description: a cross-platform library to access USB devices
Supports: !uwp
2 changes: 2 additions & 0 deletions ports/libusb/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ else()
vcpkg_install_make()
endif()

configure_file(${CURRENT_PORT_DIR}/usage ${CURRENT_PACKAGES_DIR}/share/${PORT}/usage @ONLY)
file(INSTALL ${CURRENT_PORT_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
5 changes: 5 additions & 0 deletions ports/libusb/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The package @PORT@:@TARGET_TRIPLET@ provides CMake targets:

find_package(@PORT@ CONFIG REQUIRED)
target_include_directories(main PRIVATE ${LIBUSB_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${LIBUSB_LIBRARIES})
10 changes: 10 additions & 0 deletions ports/libusb/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(SelectLibraryConfigurations)

find_path(LIBUSB_INCLUDE_DIR libusb.h PATH_SUFFIXES libusb-1.0)
find_library(LIBUSB_LIBRARY_DEBUG NAMES libusb-1.0 usb-1.0 NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH REQUIRED)
find_library(LIBUSB_LIBRARY_RELEASE NAMES libusb-1.0 usb-1.0 NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH REQUIRED)

select_library_configurations(LIBUSB)

set(LIBUSB_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIR})
set(LIBUSB_LIBRARIES ${LIBUSB_LIBRARY})

0 comments on commit 0522f98

Please sign in to comment.