From 4d84733f4817b459a200479e52269bf82514196c Mon Sep 17 00:00:00 2001 From: Nick D'Ademo Date: Mon, 9 Sep 2024 03:08:44 +0800 Subject: [PATCH] [libusbp] add new port (#40343) Co-authored-by: Nick D'Ademo Co-authored-by: Kai Pastor --- ports/libusbp/Config.cmake.in | 19 +++++++++++++++++ ports/libusbp/portfile.cmake | 39 +++++++++++++++++++++++++++++++++++ ports/libusbp/usage | 9 ++++++++ ports/libusbp/vcpkg.json | 18 ++++++++++++++++ versions/baseline.json | 4 ++++ versions/l-/libusbp.json | 9 ++++++++ 6 files changed, 98 insertions(+) create mode 100644 ports/libusbp/Config.cmake.in create mode 100644 ports/libusbp/portfile.cmake create mode 100644 ports/libusbp/usage create mode 100644 ports/libusbp/vcpkg.json create mode 100644 versions/l-/libusbp.json diff --git a/ports/libusbp/Config.cmake.in b/ports/libusbp/Config.cmake.in new file mode 100644 index 0000000000..172e08b852 --- /dev/null +++ b/ports/libusbp/Config.cmake.in @@ -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() diff --git a/ports/libusbp/portfile.cmake b/ports/libusbp/portfile.cmake new file mode 100644 index 0000000000..5758dbb729 --- /dev/null +++ b/ports/libusbp/portfile.cmake @@ -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") diff --git a/ports/libusbp/usage b/ports/libusbp/usage new file mode 100644 index 0000000000..dce51538af --- /dev/null +++ b/ports/libusbp/usage @@ -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) diff --git a/ports/libusbp/vcpkg.json b/ports/libusbp/vcpkg.json new file mode 100644 index 0000000000..031395ef97 --- /dev/null +++ b/ports/libusbp/vcpkg.json @@ -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 + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index a1349f4bae..7c7d704dfd 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -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 diff --git a/versions/l-/libusbp.json b/versions/l-/libusbp.json new file mode 100644 index 0000000000..3d112db538 --- /dev/null +++ b/versions/l-/libusbp.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "daf8ebcc9f66cd78734a4cc0f7cc9234f925d3f3", + "version": "1.3.1", + "port-version": 0 + } + ] +}