[libsrtp] Add test port, fix export config (#45150)

This commit is contained in:
Kai Pastor 2025-04-21 22:25:13 +02:00 committed by GitHub
parent 6a4ef378d0
commit d6995a0cf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 134 additions and 2 deletions

View File

@ -0,0 +1,44 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a08247a..7ccbf85 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -285,7 +285,7 @@ target_include_directories(srtp2 PUBLIC
)
if(ENABLE_OPENSSL)
target_include_directories(srtp2 PRIVATE ${OPENSSL_INCLUDE_DIR})
- target_link_libraries(srtp2 OpenSSL::Crypto)
+ target_link_libraries(srtp2 PRIVATE OpenSSL::Crypto)
elseif(ENABLE_MBEDTLS)
target_include_directories(srtp2 PRIVATE ${MBEDTLS_INCLUDE_DIRS})
target_link_libraries(srtp2 ${MBEDTLS_LIBRARIES})
@@ -294,7 +294,7 @@ elseif(ENABLE_NSS)
target_link_libraries(srtp2 ${NSS_LIBRARIES})
endif()
if(WIN32)
- target_link_libraries(srtp2 ws2_32)
+ target_link_libraries(srtp2 PRIVATE ws2_32)
target_compile_definitions(srtp2 PUBLIC _CRT_SECURE_NO_WARNINGS)
endif()
@@ -491,7 +491,7 @@ include(CMakePackageConfigHelpers)
# Generate the config file that is includes the exports
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/libSRTPConfig.cmake"
- INSTALL_DESTINATION "${CONFIG_FILE_DIR}"
+ INSTALL_DESTINATION lib/cmake/libSRTP
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
diff --git a/Config.cmake.in b/Config.cmake.in
index 0ad9b17..c9ce5a7 100644
--- a/Config.cmake.in
+++ b/Config.cmake.in
@@ -1,3 +1,8 @@
@PACKAGE_INIT@
+if("@ENABLE_OPENSSL@")
+ include(CMakeFindDependencyMacro)
+ find_dependency(OpenSSL)
+endif()
+
include ( "${CMAKE_CURRENT_LIST_DIR}/libSRTPTargets.cmake" )

View File

@ -1,3 +1,20 @@
if(MSVC)
string(APPEND CMAKE_CFLAGS " /wd4703")
endif()
block(SCOPE_FOR VARIABLES)
set(prefix [[${pcfiledir}/../..]])
set(libdir [[${prefix}/lib]])
set(includedir [[${prefix}/include]])
set(PACKAGE_NAME "${PROJECT_NAME}")
set(PACKAGE_VERSION "${PROJECT_VERSION}")
set(LIBS "")
if(WIN32)
set(LIBS "-lws2_32")
endif()
configure_file("${PROJECT_SOURCE_DIR}/libsrtp2.pc.in" "${PROJECT_BINARY_DIR}/libsrtp2.pc" @ONLY)
if(ENABLE_OPENSSL)
file(APPEND "${PROJECT_BINARY_DIR}/libsrtp2.pc" "Requires.private: libcrypto")
endif()
install(FILES "${PROJECT_BINARY_DIR}/libsrtp2.pc" DESTINATION "lib/pkgconfig")
endblock()

View File

@ -4,6 +4,7 @@ vcpkg_from_github(
REF "v${VERSION}"
SHA512 eb42cc1755acd5677351fc058e2f45314ba66b590bce80944ea12aa3780953ce4c1c6211979729304d753e6c0fd325647adafc38c20c6af8482ce6f552022896
PATCHES
cmake-config.diff
fix-runtime-destination.patch
)
@ -21,8 +22,8 @@ vcpkg_cmake_configure(
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libSRTP)
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

View File

@ -1,6 +1,7 @@
{
"name": "libsrtp",
"version": "2.7.0",
"port-version": 1,
"description": "This package provides an implementation of the Secure Real-time Transport Protocol (SRTP), the Universal Security Transform (UST), and a supporting cryptographic kernel.",
"homepage": "https://github.com/cisco/libsrtp/",
"license": "BSD-3-Clause",

View File

@ -0,0 +1,10 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)
vcpkg_cmake_build()

View File

@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.30)
project(libsrtp-test C)
find_package(libSRTP CONFIG REQUIRED)
add_executable(main main.c)
target_link_libraries(main PRIVATE libSRTP::srtp2)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libsrtp_pc libsrtp2 REQUIRED IMPORTED_TARGET)
add_executable(main-pkconfig main.c)
target_link_libraries(main-pkconfig PRIVATE PkgConfig::libsrtp_pc)

View File

@ -0,0 +1,8 @@
#include <stdio.h>
#include <srtp2/srtp.h>
int main()
{
printf("libsrtp versions: %s\n", srtp_get_version_string());
return 0;
}

View File

@ -0,0 +1,33 @@
{
"name": "vcpkg-ci-libsrtp",
"version-string": "ci",
"description": "Port to force features of libsrtp within CI",
"homepage": "https://github.com/microsoft/vcpkg",
"license": "MIT",
"dependencies": [
{
"name": "libsrtp",
"default-features": false
},
{
"name": "vcpkg-cmake",
"host": true
}
],
"default-features": [
"all"
],
"features": {
"all": {
"description": "Test all features",
"dependencies": [
{
"name": "libsrtp",
"features": [
"openssl"
]
}
]
}
}
}

View File

@ -5306,7 +5306,7 @@
},
"libsrtp": {
"baseline": "2.7.0",
"port-version": 0
"port-version": 1
},
"libssh": {
"baseline": "0.10.6",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "eae4adb49b2e66ded0e95785dee1155b587addf1",
"version": "2.7.0",
"port-version": 1
},
{
"git-tree": "0f04591cad0e2ac930c04051a0f62a440dc8753c",
"version": "2.7.0",