Skip to content

Commit

Permalink
[libusbp] add new port (#40343)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick D'Ademo <[email protected]>
Co-authored-by: Kai Pastor <[email protected]>
  • Loading branch information
3 people authored Sep 8, 2024
1 parent a01cae2 commit 4d84733
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ports/libusbp/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if(NOT TARGET unofficial::libusbp::libusbp)
add_library(unofficial::libusbp::libusbp UNKNOWN IMPORTED)

set_target_properties(unofficial::libusbp::libusbp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/libusbp-1"
)

find_library(libusbp_LIBRARY_RELEASE NAMES usbp-1 PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH)
if(EXISTS "${libusbp_LIBRARY_RELEASE}")
set_property(TARGET unofficial::libusbp::libusbp APPEND PROPERTY IMPORTED_CONFIGURATIONS "Release")
set_target_properties(unofficial::libusbp::libusbp PROPERTIES IMPORTED_LOCATION_RELEASE "${libusbp_LIBRARY_RELEASE}")
endif()

find_library(libusbp_LIBRARY_DEBUG NAMES usbp-1 PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH)
if(EXISTS "${libusbp_LIBRARY_DEBUG}")
set_property(TARGET unofficial::libusbp::libusbp APPEND PROPERTY IMPORTED_CONFIGURATIONS "Debug")
set_target_properties(unofficial::libusbp::libusbp PROPERTIES IMPORTED_LOCATION_DEBUG "${libusbp_LIBRARY_DEBUG}")
endif()
endif()
39 changes: 39 additions & 0 deletions ports/libusbp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(
"${PORT} currently requires the following libraries from the system package manager:
libudev-dev
These can be installed on Ubuntu systems via sudo apt install libudev-dev"
)
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pololu/libusbp
REF "${VERSION}"
SHA512 3705ab40b65323eab788592b1b5e1cd94ef1d7ee55fb0f2919013a8bdb488eb83e257623a8be8c5230a74eaea1c0fd8a5926a8a399f0d2f6eebcd82ec0a01c4d
HEAD_REF master
)

vcpkg_find_acquire_program(PKGCONFIG)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)

vcpkg_cmake_install()
vcpkg_copy_pdbs()

vcpkg_fixup_pkgconfig()

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin" "${CURRENT_PACKAGES_DIR}/bin")
endif()

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

configure_file("${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake" @ONLY)

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
9 changes: 9 additions & 0 deletions ports/libusbp/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
libusbp provides pkg-config modules:

# Library for accessing USB devices.
libusbp

libusbp provides CMake targets:

find_package(unofficial-libusbp CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::libusbp::libusbp)
18 changes: 18 additions & 0 deletions ports/libusbp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "libusbp",
"version": "1.3.1",
"description": "The Pololu USB Library (also known as libusbp) is a cross-platform C library for accessing USB devices.",
"homepage": "https://github.com/pololu/libusbp",
"license": "MIT",
"supports": "!android & !uwp",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5220,6 +5220,10 @@
"baseline": "2023-06-21",
"port-version": 1
},
"libusbp": {
"baseline": "1.3.1",
"port-version": 0
},
"libuuid": {
"baseline": "1.0.3",
"port-version": 14
Expand Down
9 changes: 9 additions & 0 deletions versions/l-/libusbp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "daf8ebcc9f66cd78734a4cc0f7cc9234f925d3f3",
"version": "1.3.1",
"port-version": 0
}
]
}

0 comments on commit 4d84733

Please sign in to comment.