Merge pull request #220 from paullouisageneau/cmake-srtp-option

Add cmake USE_SRTP option
This commit is contained in:
Paul-Louis Ageneau
2020-10-25 09:11:40 +01:00
committed by GitHub

View File

@ -12,6 +12,9 @@ option(NO_EXAMPLES "Disable examples" OFF)
option(NO_TESTS "Disable tests build" OFF)
option(WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
option(CAPI_STDCALL "Set calling convention of C API callbacks stdcall" OFF)
# Option USE_SRTP defaults to AUTO (enabled if libSRTP is found, else disabled)
set(USE_SRTP AUTO CACHE STRING "Use libSRTP and enable media support")
set_property(CACHE USE_SRTP PROPERTY STRINGS AUTO ON OFF)
if(USE_NICE)
option(USE_JUICE "Use libjuice" OFF)
@ -20,9 +23,9 @@ else()
endif()
if(USE_GNUTLS)
option(USE_NETTLE "Use Nettle instead of OpenSSL in libjuice" ON)
option(USE_NETTLE "Use Nettle in libjuice" ON)
else()
option(USE_NETTLE "Use Nettle instead of OpenSSL in libjuice" OFF)
option(USE_NETTLE "Use Nettle in libjuice" OFF)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -162,8 +165,18 @@ if(WIN32)
target_link_libraries(datachannel-static PRIVATE ws2_32) # winsock2
endif()
find_package(SRTP)
if(SRTP_FOUND)
if(USE_SRTP STREQUAL "AUTO")
find_package(SRTP)
if(SRTP_FOUND)
message(STATUS "LibSRTP found, compiling with media transport")
else()
message(STATUS "LibSRTP NOT found, compiling WITHOUT media transport")
endif()
elseif(USE_SRTP)
find_package(SRTP REQUIRED)
endif()
if(USE_SRTP AND SRTP_FOUND)
if(NOT TARGET SRTP::SRTP)
add_library(SRTP::SRTP UNKNOWN IMPORTED)
set_target_properties(SRTP::SRTP PROPERTIES
@ -171,13 +184,11 @@ if(SRTP_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES C
IMPORTED_LOCATION ${SRTP_LIBRARIES})
endif()
message(STATUS "LibSRTP found, compiling with media transport")
target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=1)
target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=1)
target_link_libraries(datachannel PRIVATE SRTP::SRTP)
target_link_libraries(datachannel-static PRIVATE SRTP::SRTP)
else()
message(STATUS "LibSRTP NOT found, compiling WITHOUT media transport")
target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=0)
target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=0)
endif()