Skip to content

Commit

Permalink
[libdatachannel] Update, cleanup (microsoft#40337)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored Aug 9, 2024
1 parent dff78ec commit 8ae59b5
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 124 deletions.
63 changes: 63 additions & 0 deletions ports/libdatachannel/dependencies.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a61757..b35e4b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -234,7 +234,7 @@ set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)

if(USE_SYSTEM_PLOG)
- find_package(plog REQUIRED)
+ find_package(plog CONFIG REQUIRED)
else()
set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
add_subdirectory(deps/plog EXCLUDE_FROM_ALL)
@@ -245,7 +245,8 @@ if(SCTP_DEBUG)
endif()

if(USE_SYSTEM_USRSCTP)
- find_package(Usrsctp REQUIRED)
+ find_package(unofficial-usrsctp CONFIG REQUIRED)
+ add_library(Usrsctp::Usrsctp ALIAS unofficial::usrsctp::usrsctp)
else()
option(sctp_build_shared_lib OFF)
option(sctp_build_programs OFF)
@@ -331,7 +332,7 @@ else()
target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=1)
target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=1)
if(USE_SYSTEM_SRTP)
- find_package(libSRTP REQUIRED)
+ find_package(libSRTP CONFIG REQUIRED)
if(NOT TARGET libSRTP::srtp2)
add_library(libSRTP::srtp2 UNKNOWN IMPORTED)
set_target_properties(libSRTP::srtp2 PROPERTIES
@@ -475,8 +476,9 @@ install(
)

# Export config
+configure_file(cmake/LibDataChannelConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/LibDataChannelConfig.cmake @ONLY)
install(
- FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibDataChannelConfig.cmake
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/LibDataChannelConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibDataChannel
)

diff --git a/cmake/LibDataChannelConfig.cmake b/cmake/LibDataChannelConfig.cmake
index cb2b884..d0b77ca 100644
--- a/cmake/LibDataChannelConfig.cmake
+++ b/cmake/LibDataChannelConfig.cmake
@@ -1,2 +1,15 @@
+if(NOT "@BUILD_SHARED_LIBS@")
+ include(CMakeFindDependencyMacro)
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
+ find_dependency(Threads)
+ find_dependency(plog CONFIG)
+ find_dependency(unofficial-usrsctp CONFIG)
+ if(NOT "@NO_MEDIA@")
+ find_dependency(libSRTP CONFIG)
+ endif()
+ find_dependency(OpenSSL)
+ find_dependency(LibJuice)
+endif()
+
include("${CMAKE_CURRENT_LIST_DIR}/LibDataChannelTargets.cmake")

30 changes: 0 additions & 30 deletions ports/libdatachannel/fix-for-vcpkg.patch

This file was deleted.

40 changes: 0 additions & 40 deletions ports/libdatachannel/fix_dependency.patch

This file was deleted.

13 changes: 0 additions & 13 deletions ports/libdatachannel/fix_srtp.patch

This file was deleted.

22 changes: 22 additions & 0 deletions ports/libdatachannel/library-linkage.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b35e4b1..1b5190b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -457,11 +457,17 @@ if(WARNINGS_AS_ERRORS)
endif()
endif()

+if(BUILD_SHARED_LIBS)
install(TARGETS datachannel EXPORT LibDataChannelTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
+else()
+ set_target_properties(datachannel PROPERTIES EXCLUDE_FROM_ALL 1)
+ set_target_properties(datachannel-static PROPERTIES EXCLUDE_FROM_ALL 0)
+ install(TARGETS datachannel-static EXPORT LibDataChannelTargets)
+endif()

install(FILES ${LIBDATACHANNEL_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rtc
39 changes: 9 additions & 30 deletions ports/libdatachannel/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
set(PATCHES fix-for-vcpkg.patch)

if(VCPKG_TARGET_IS_UWP)
list(APPEND PATCHES uwp-warnings.patch)
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO paullouisageneau/libdatachannel
REF "v${VERSION}"
SHA512 67119f6d1280593696f71dc550ceba1076066d0f55ebf10b527bf1c75e5e9571be18e5d9732e43a2aa4d5106a49a0676e70938d35d3eb4005cf17612f8836c52
SHA512 fd0d66bb932e29abc01e9f1a8b16ccb79012a7e3901e2e0f882f56ab2f090260945e1556c85ad07ef897b8c70fcdd44cdeead9955a9bca7afe1dda8900c473cc
HEAD_REF master
PATCHES
${PATCHES}
fix_dependency.patch
dependencies.diff
library-linkage.diff
uwp-warnings.patch
)
file(REMOVE "${SOURCE_PATH}/cmake/Modules/FindLibJuice.cmake")
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" DATACHANNEL_STATIC_LINKAGE)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
stdcall CAPI_STDCALL
INVERTED_FEATURES
ws NO_WEBSOCKET
srtp NO_MEDIA
ws NO_WEBSOCKET
srtp NO_MEDIA
)

vcpkg_cmake_configure(
Expand All @@ -32,30 +25,16 @@ vcpkg_cmake_configure(
-DPREFER_SYSTEM_LIB=ON
-DNO_EXAMPLES=ON
-DNO_TESTS=ON
-DDATACHANNEL_STATIC_LINKAGE=${DATACHANNEL_STATIC_LINKAGE}
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(PACKAGE_NAME LibDataChannel CONFIG_PATH lib/cmake/LibDataChannel)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/LibDataChannel)
vcpkg_fixup_pkgconfig()

if(srtp IN_LIST FEATURES)
set(FIND_DEP_SRTP "find_dependency(libSRTP CONFIG)")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/rtc/common.hpp" "#ifdef RTC_STATIC" "#if 1")
endif()

file(READ "${CURRENT_PACKAGES_DIR}/share/LibDataChannel/LibDataChannelConfig.cmake" DATACHANNEL_CONFIG)
file(WRITE "${CURRENT_PACKAGES_DIR}/share/LibDataChannel/LibDataChannelConfig.cmake" "
include(CMakeFindDependencyMacro)
find_dependency(Threads)
find_dependency(OpenSSL)
find_dependency(LibJuice)
find_dependency(plog CONFIG)
find_dependency(unofficial-usrsctp CONFIG)
${FIND_DEP_SRTP}
${DATACHANNEL_CONFIG}")


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

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
19 changes: 10 additions & 9 deletions ports/libdatachannel/uwp-warnings.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2c34d7fb..1bedd212 100644
index 1b5190b..763b49e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -446,6 +446,9 @@ if(WARNINGS_AS_ERRORS)
endif()
@@ -315,6 +315,10 @@ target_link_libraries(datachannel-static PRIVATE Usrsctp::Usrsctp plog::plog)
if(WIN32)
target_link_libraries(datachannel PUBLIC ws2_32) # winsock2
target_link_libraries(datachannel-static PUBLIC ws2_32) # winsock2
+ if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+ target_compile_options(datachannel PRIVATE /wd4996)
+ target_compile_options(datachannel-static PRIVATE /wd4996)
+ endif()
endif()

+target_compile_options(datachannel PRIVATE /wd4996)
+target_compile_options(datachannel-static PRIVATE /wd4996)
+
if(DATACHANNEL_STATIC_LINKAGE)
set_target_properties(datachannel PROPERTIES EXCLUDE_FROM_ALL 1)
set_target_properties(datachannel-static PROPERTIES EXCLUDE_FROM_ALL 0)
if (NO_WEBSOCKET)
2 changes: 1 addition & 1 deletion ports/libdatachannel/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libdatachannel",
"version-semver": "0.21.1",
"version-semver": "0.21.2",
"description": "libdatachannel is a standalone implementation of WebRTC Data Channels, WebRTC Media Transport, and WebSockets in C++17 with C bindings for POSIX platforms (including GNU/Linux, Android, and Apple macOS) and Microsoft Windows.",
"homepage": "https://github.com/paullouisageneau/libdatachannel",
"license": "MPL-2.0",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4349,7 +4349,7 @@
"port-version": 0
},
"libdatachannel": {
"baseline": "0.21.1",
"baseline": "0.21.2",
"port-version": 0
},
"libdatrie": {
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libdatachannel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "7ef5c0cdf31856f7b73f1498dd8055627608801c",
"version-semver": "0.21.2",
"port-version": 0
},
{
"git-tree": "f5218e93bae8971d509fd04910f9778004e58bce",
"version-semver": "0.21.1",
Expand Down

0 comments on commit 8ae59b5

Please sign in to comment.