From b080adb550f9805eec98879b38737e9fd5ea2133 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Fri, 2 Aug 2024 04:01:30 +0300 Subject: [PATCH] CMake: Unbundle libSRTP --- CMakeLists.txt | 10 +++++++--- cmake/external.cmake | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e23f05051..46eccff2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,6 @@ include(cmake/generate_field_trials.cmake) include(cmake/external.cmake) include(cmake/libpffft.cmake) include(cmake/librnnoise.cmake) -include(cmake/libsrtp.cmake) include(cmake/libyuv.cmake) if (APPLE) include(cmake/libsdkmacos.cmake) @@ -132,7 +131,6 @@ target_link_libraries(tg_owt PRIVATE tg_owt::libpffft tg_owt::librnnoise - tg_owt::libsrtp tg_owt::libyuv ) @@ -153,6 +151,7 @@ link_ffmpeg(tg_owt) link_opus(tg_owt) link_libabsl(tg_owt) link_libopenh264(tg_owt) +link_libsrtp(tg_owt) link_libvpx(tg_owt) link_crc32c(tg_owt) link_dl(tg_owt) @@ -2631,13 +2630,18 @@ list(APPEND export_targets libwebrtcbuild libpffft librnnoise - libsrtp libyuv ) if (NOT absl_FOUND) include(cmake/libabsl.cmake) list(APPEND export_targets libabsl) endif() +if (NOT SRTP_FOUND) + include(cmake/libsrtp.cmake) + list(APPEND export_targets libsrtp) +else() + target_compile_definitions(tg_owt PRIVATE WEBRTC_EXTERNAL_SRTP) +endif() if (NOT Crc32c_FOUND) include(cmake/libcrc32c.cmake) list(APPEND export_targets libcrc32c) diff --git a/cmake/external.cmake b/cmake/external.cmake index 1c71f8518..d94354718 100644 --- a/cmake/external.cmake +++ b/cmake/external.cmake @@ -150,6 +150,21 @@ function(link_libopenh264 target_name) endif() endfunction() +# libSRTP +function(link_libsrtp target_name) + if (TG_OWT_PACKAGED_BUILD) + find_package(PkgConfig REQUIRED) + pkg_check_modules(SRTP libsrtp2) + if (SRTP_FOUND) + target_include_directories(${target_name} SYSTEM PRIVATE ${SRTP_INCLUDE_DIRS}) + target_link_libraries(${target_name} PRIVATE ${SRTP_LINK_LIBRARIES}) + endif() + endif() + if (NOT SRTP_FOUND) + target_link_libraries(${target_name} PRIVATE tg_owt::libsrtp) + endif() +endfunction() + # libvpx set(TG_OWT_LIBVPX_INCLUDE_PATH "" CACHE STRING "Include path for libvpx.") function(link_libvpx target_name)