From c39217bc52e4917e17971cc026bb861f40846264 Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Tue, 2 Dec 2025 00:24:17 +0100 Subject: [PATCH] [libupnp] Add new port for libupnp (pupnp) (#48267) --- ports/libupnp/fix-pthreads4w-targets.patch | 13 +++++ ports/libupnp/portfile.cmake | 58 ++++++++++++++++++++++ ports/libupnp/usage | 18 +++++++ ports/libupnp/vcpkg.json | 37 ++++++++++++++ versions/baseline.json | 4 ++ versions/l-/libupnp.json | 9 ++++ 6 files changed, 139 insertions(+) create mode 100644 ports/libupnp/fix-pthreads4w-targets.patch create mode 100644 ports/libupnp/portfile.cmake create mode 100644 ports/libupnp/usage create mode 100644 ports/libupnp/vcpkg.json create mode 100644 versions/l-/libupnp.json diff --git a/ports/libupnp/fix-pthreads4w-targets.patch b/ports/libupnp/fix-pthreads4w-targets.patch new file mode 100644 index 0000000000..f4dce23d01 --- /dev/null +++ b/ports/libupnp/fix-pthreads4w-targets.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 45c13c195d..7eb05f7277 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -226,6 +226,8 @@ if(NOT MSVC) + endif() + else() + find_package(PTHREADS4W CONFIG REQUIRED) ++ add_library(Threads::Shared ALIAS PThreads4W::PThreads4W) ++ add_library(Threads::Static ALIAS PThreads4W::PThreads4W) + endif() + + # diff --git a/ports/libupnp/portfile.cmake b/ports/libupnp/portfile.cmake new file mode 100644 index 0000000000..0e0a4528bb --- /dev/null +++ b/ports/libupnp/portfile.cmake @@ -0,0 +1,58 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO pupnp/pupnp + REF "release-${VERSION}" + SHA512 2aed5c72cb8e33b89d85e6755b99e7bd4e82ffb58d03ef58c2cdd790d4dc6c33b3a9f91168595930be53f0bb803e266e2bb02ea5fcc5cda8edada9453bf56492 + PATCHES + fix-pthreads4w-targets.patch +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" LIBUPNP_BUILD_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" LIBUPNP_BUILD_SHARED) + +if(LIBUPNP_BUILD_STATIC) + set(UPNP_TARGET "Static") +else() + set(UPNP_TARGET "Shared") +endif() + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + client-api UPNP_ENABLE_CLIENT_API + ipv6 UPNP_ENABLE_IPV6 + ssl UPNP_ENABLE_OPEN_SSL + webserver UPNP_ENABLE_WEBSERVER +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_TESTING=OFF + -DIXML_ENABLE_SCRIPT_SUPPORT=ON + -DUPNP_ENABLE_GENA=ON + -DUPNP_ENABLE_SOAP=ON + -DUPNP_ENABLE_SSDP=ON + -DUPNP_ENABLE_BLOCKING_TCP_CONNECTIONS=OFF + -DUPNP_ENABLE_DEVICE_API=${UPNP_ENABLE_WEBSERVER} + -DUPNP_MINISERVER_REUSEADDR=${UPNP_ENABLE_WEBSERVER} + -DUPNP_BUILD_SHARED=${LIBUPNP_BUILD_SHARED} + -DUPNP_BUILD_STATIC=${LIBUPNP_BUILD_STATIC} + -DUPNP_BUILD_SAMPLES=OFF + -DUPNP_ENABLE_UNSPECIFIED_SERVER=OFF + ${FEATURE_OPTIONS} +) + +vcpkg_cmake_install() + +vcpkg_fixup_pkgconfig() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/UPNP DO_NOT_DELETE_PARENT_CONFIG_PATH) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/IXML) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +vcpkg_copy_pdbs() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/libupnp/usage b/ports/libupnp/usage new file mode 100644 index 0000000000..9aa4f207c7 --- /dev/null +++ b/ports/libupnp/usage @@ -0,0 +1,18 @@ +libupnp provides pkg-config modules: + + # Linux SDK for UPnP Devices + libupnp + +libupnp provides CMake targets: + + find_package(UPNP CONFIG REQUIRED) + target_link_libraries(main PRIVATE UPNP::Shared) + -- or -- + target_link_libraries(main PRIVATE UPNP::Static) + +libixml provides CMake targets: + + find_package(IXML CONFIG REQUIRED) + target_link_libraries(main PRIVATE IXML::Shared) + -- or -- + target_link_libraries(main PRIVATE IXML::Static) diff --git a/ports/libupnp/vcpkg.json b/ports/libupnp/vcpkg.json new file mode 100644 index 0000000000..1311d2547a --- /dev/null +++ b/ports/libupnp/vcpkg.json @@ -0,0 +1,37 @@ +{ + "name": "libupnp", + "version": "1.14.25", + "description": "libupnp: Build UPnP-compliant control points, devices, and bridges on several operating systems.", + "homepage": "https://github.com/pupnp/pupnp/", + "documentation": "https://github.com/pupnp/pupnp/", + "license": "BSD-3-Clause", + "supports": "!uwp", + "dependencies": [ + "pthreads", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "client-api": { + "description": "Enable control point code (client)" + }, + "ipv6": { + "description": "Enable IPv6 support" + }, + "ssl": { + "description": "OpenSSL support for encrypted connections", + "dependencies": [ + "openssl" + ] + }, + "webserver": { + "description": "Enable integrated webserver" + } + } +} diff --git a/versions/baseline.json b/versions/baseline.json index 1dfe5559dd..06908785d3 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5660,6 +5660,10 @@ "baseline": "1.8.3", "port-version": 0 }, + "libupnp": { + "baseline": "1.14.25", + "port-version": 0 + }, "liburcu": { "baseline": "0.15.2", "port-version": 0 diff --git a/versions/l-/libupnp.json b/versions/l-/libupnp.json new file mode 100644 index 0000000000..58371a177a --- /dev/null +++ b/versions/l-/libupnp.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "49cc2e5824590583f7277390e1e74512cfa56889", + "version": "1.14.25", + "port-version": 0 + } + ] +}