From b5bf930467cc14edd22577dd90662f64f6c52120 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Tue, 6 Apr 2021 18:30:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4cmake?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 21 +++++++++++++++++---- cmake/FindSRTP.cmake | 4 ++-- webrtc/CMakeLists.txt | 16 ---------------- 3 files changed, 19 insertions(+), 22 deletions(-) delete mode 100644 webrtc/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 36a93a12..54bfed8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,10 +225,23 @@ if(ENABLE_API) add_subdirectory(api) endif() -if(ENABLE_WEBRTC) - add_definitions(-DENABLE_WEBRTC) - add_subdirectory(webrtc) -endif() +if (ENABLE_WEBRTC) + #查找srtp是否安装 + find_package(SRTP QUIET) + if (SRTP_FOUND) + message(STATUS "found library:${SRTP_LIBRARIES}") + include_directories(${SRTP_INCLUDE_DIRS}) + list(APPEND LINK_LIB_LIST ${SRTP_LIBRARIES}) + + add_definitions(-DENABLE_WEBRTC) + include_directories(./webrtc) + file(GLOB SRC_WEBRTC_LIST ./webrtc/*.cpp ./webrtc/*.h ./webrtc/*.hpp) + add_library(webrtc ${SRC_WEBRTC_LIST}) + list(APPEND LINK_LIB_LIST webrtc) + else () + message(WARNING "srtp未找到, webrtc相关功能打开失败") + endif () +endif () if (NOT IOS) #测试程序 diff --git a/cmake/FindSRTP.cmake b/cmake/FindSRTP.cmake index 3046020e..8d88f405 100644 --- a/cmake/FindSRTP.cmake +++ b/cmake/FindSRTP.cmake @@ -32,7 +32,7 @@ set(_SRTP_ROOT_PATHS find_path(SRTP_INCLUDE_DIRS NAMES srtp2/srtp.h - HINTS _SRTP_ROOT_PATHS + HINTS _SRTP_ROOT_PATHS ${SRTP_PREFIX} PATH_SUFFIXES include ) @@ -42,7 +42,7 @@ endif() find_library(SRTP_LIBRARIES NAMES srtp2 - HINTS ${_SRTP_ROOT_PATHS} + HINTS ${_SRTP_ROOT_PATHS} ${SRTP_PREFIX} PATH_SUFFIXES bin lib ) diff --git a/webrtc/CMakeLists.txt b/webrtc/CMakeLists.txt deleted file mode 100644 index db7dd3a8..00000000 --- a/webrtc/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -list(APPEND LINK_LIB_LIST webrtc) -#查找srtp是否安装 -find_package(SRTP QUIET) -if (SRTP_FOUND) - message(STATUS "found library:${SRTP_LIBRARIES}") - include_directories(${SRTP_INCLUDE_DIRS}) - list(APPEND LINK_LIB_LIST ${SRTP_LIBRARIES}) -else () - message(FATAL_ERROR "srtp未找到!") -endif () - -include_directories(./) -file(GLOB SRC_LIST ./*.cpp ./*.h ./*.hpp) -add_library(webrtc ${SRC_LIST}) -set(LINK_LIB_LIST ${LINK_LIB_LIST} PARENT_SCOPE) -