mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 18:50:20 +08:00
整理 CMakeLists.txt
This commit is contained in:
parent
8192b37cd4
commit
9d3ead61de
185
3rdpart/CMakeLists.txt
Normal file
185
3rdpart/CMakeLists.txt
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# jsoncpp
|
||||||
|
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp JSONCPP_SRC_LIST)
|
||||||
|
add_library(jsoncpp STATIC ${JSONCPP_SRC_LIST})
|
||||||
|
target_compile_options(jsoncpp
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_include_directories(jsoncpp
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
|
||||||
|
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES jsoncpp)
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# media-server
|
||||||
|
set(MediaServer_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/media-server")
|
||||||
|
# TODO: 补一个函数处理各种库
|
||||||
|
|
||||||
|
# 添加 mov、flv 库用于 MP4 录制
|
||||||
|
if(ENABLE_MP4)
|
||||||
|
message(STATUS "ENABLE_MP4 defined")
|
||||||
|
|
||||||
|
# MOV
|
||||||
|
set(MediaServer_MOV_ROOT ${MediaServer_ROOT}/libmov)
|
||||||
|
aux_source_directory(${MediaServer_MOV_ROOT}/include MOV_SRC_LIST)
|
||||||
|
aux_source_directory(${MediaServer_MOV_ROOT}/source MOV_SRC_LIST)
|
||||||
|
add_library(mov STATIC ${MOV_SRC_LIST})
|
||||||
|
add_library(MediaServer::mov ALIAS mov)
|
||||||
|
target_compile_definitions(mov
|
||||||
|
PUBLIC -DENABLE_MP4)
|
||||||
|
target_compile_options(mov
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_include_directories(mov
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${MediaServer_MOV_ROOT}/include>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${MediaServer_MOV_ROOT}/include>")
|
||||||
|
|
||||||
|
# FLV
|
||||||
|
set(MediaServer_FLV_ROOT ${MediaServer_ROOT}/libflv)
|
||||||
|
aux_source_directory(${MediaServer_FLV_ROOT}/include FLV_SRC_LIST)
|
||||||
|
aux_source_directory(${MediaServer_FLV_ROOT}/source FLV_SRC_LIST)
|
||||||
|
add_library(flv STATIC ${FLV_SRC_LIST})
|
||||||
|
add_library(MediaServer::flv ALIAS flv)
|
||||||
|
target_compile_options(flv
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_include_directories(flv
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${MediaServer_FLV_ROOT}/include>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${MediaServer_FLV_ROOT}/include>")
|
||||||
|
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES
|
||||||
|
MediaServer::flv MediaServer::mov)
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS
|
||||||
|
ENABLE_MP4)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# 添加 mpeg 用于支持 ts 生成
|
||||||
|
if(ENABLE_RTPPROXY OR ENABLE_HLS)
|
||||||
|
# mpeg
|
||||||
|
set(MediaServer_MPEG_ROOT ${MediaServer_ROOT}/libmpeg)
|
||||||
|
aux_source_directory(${MediaServer_MPEG_ROOT}/include MPEG_SRC_LIST)
|
||||||
|
aux_source_directory(${MediaServer_MPEG_ROOT}/source MPEG_SRC_LIST)
|
||||||
|
add_library(mpeg STATIC ${MPEG_SRC_LIST})
|
||||||
|
add_library(MediaServer::mpeg ALIAS mpeg)
|
||||||
|
target_compile_options(mpeg
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_include_directories(mpeg
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${MediaServer_MPEG_ROOT}/include>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${MediaServer_MPEG_ROOT}/include>")
|
||||||
|
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES MediaServer::mpeg)
|
||||||
|
if(ENABLE_RTPPROXY)
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_RTPPROXY)
|
||||||
|
endif()
|
||||||
|
if(ENABLE_HLS)
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_HLS)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# toolkit
|
||||||
|
# TODO: 改造 toolkit 以便直接引用
|
||||||
|
|
||||||
|
include(CheckStructHasMember)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
|
||||||
|
# 检查 sendmmsg 相关依赖并设置对应的宏
|
||||||
|
#list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
||||||
|
check_struct_has_member("struct mmsghdr" msg_hdr sys/socket.h HAVE_MMSG_HDR)
|
||||||
|
check_symbol_exists(sendmmsg sys/socket.h HAVE_SENDMMSG_API)
|
||||||
|
check_symbol_exists(recvmmsg sys/socket.h HAVE_RECVMMSG_API)
|
||||||
|
|
||||||
|
set(COMPILE_DEFINITIONS)
|
||||||
|
if(HAVE_MMSG_HDR)
|
||||||
|
list(APPEND COMPILE_DEFINITIONS HAVE_MMSG_HDR)
|
||||||
|
endif()
|
||||||
|
if(HAVE_SENDMMSG_API)
|
||||||
|
list(APPEND COMPILE_DEFINITIONS HAVE_SENDMMSG_API)
|
||||||
|
endif()
|
||||||
|
if(HAVE_RECVMMSG_API)
|
||||||
|
list(APPEND COMPILE_DEFINITIONS HAVE_RECVMMSG_API)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ToolKit_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/ZLToolKit)
|
||||||
|
# 收集源代码
|
||||||
|
file(GLOB ToolKit_SRC_LIST
|
||||||
|
${ToolKit_ROOT}/src/*/*.cpp
|
||||||
|
${ToolKit_ROOT}/src/*/*.h
|
||||||
|
${ToolKit_ROOT}/src/*/*.c)
|
||||||
|
if(IOS)
|
||||||
|
list(APPEND ToolKit_SRC_LIST
|
||||||
|
${ToolKit_ROOT}/Network/Socket_ios.mm)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# 去除 win32 的适配代码
|
||||||
|
if(NOT WIN32)
|
||||||
|
list(REMOVE_ITEM ToolKit_SRC_LIST ${ToolKit_ROOT}/win32/getopt.c)
|
||||||
|
else()
|
||||||
|
# 防止 Windows.h 包含 Winsock.h
|
||||||
|
list(APPEND COMPILE_DEFINITIONS
|
||||||
|
WIN32_LEAN_AND_MEAN MP4V2_NO_STDINT_DEFS
|
||||||
|
# 禁用警告
|
||||||
|
_CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# 添加库
|
||||||
|
add_library(zltoolkit STATIC ${ToolKit_SRC_LIST})
|
||||||
|
add_library(ZLMediaKit::ToolKit ALIAS zltoolkit)
|
||||||
|
target_compile_definitions(zltoolkit
|
||||||
|
PRIVATE ${COMPILE_DEFINITIONS})
|
||||||
|
target_compile_options(zltoolkit
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_include_directories(zltoolkit
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${ToolKit_ROOT}/src>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${ToolKit_ROOT}>/src")
|
||||||
|
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES ZLMediaKit::ToolKit)
|
||||||
|
|
||||||
|
if(USE_SOLUTION_FOLDERS AND (NOT GROUP_BY_EXPLORER))
|
||||||
|
# 在 IDE 中对文件进行分组, 源文件和头文件分开
|
||||||
|
set_file_group(${ToolKit_ROOT}/src ${ToolKit_SRC_LIST})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# 未在使用
|
||||||
|
if(ENABLE_CXX_API)
|
||||||
|
# 保留目录结构
|
||||||
|
install(DIRECTORY ${ToolKit_ROOT}/
|
||||||
|
DESTINATION ${INSTALL_PATH_INCLUDE}/ZLToolKit
|
||||||
|
REGEX "(.*[.](md|cpp)|win32)$" EXCLUDE)
|
||||||
|
install(TARGETS zltoolkit
|
||||||
|
DESTINATION ${INSTALL_PATH_LIB})
|
||||||
|
endif()
|
623
CMakeLists.txt
623
CMakeLists.txt
@ -1,126 +1,144 @@
|
|||||||
project(ZLMediaKit)
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.1.3)
|
cmake_minimum_required(VERSION 3.1.3)
|
||||||
include(CheckStructHasMember)
|
|
||||||
include(CheckSymbolExists)
|
|
||||||
|
|
||||||
# 检查sendmmsg相关依赖并设置对应的宏
|
|
||||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
|
||||||
check_struct_has_member("struct mmsghdr" msg_hdr sys/socket.h HAVE_MMSG_HDR)
|
|
||||||
check_symbol_exists(sendmmsg sys/socket.h HAVE_SENDMMSG_API)
|
|
||||||
check_symbol_exists(recvmmsg sys/socket.h HAVE_RECVMMSG_API)
|
|
||||||
|
|
||||||
if(HAVE_MMSG_HDR)
|
|
||||||
add_definitions(-DHAVE_MMSG_HDR)
|
|
||||||
endif()
|
|
||||||
if(HAVE_SENDMMSG_API)
|
|
||||||
add_definitions(-DHAVE_SENDMMSG_API)
|
|
||||||
endif()
|
|
||||||
if(HAVE_RECVMMSG_API)
|
|
||||||
add_definitions(-DHAVE_RECVMMSG_API)
|
|
||||||
endif()
|
|
||||||
#使能c++11
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
# 加载自定义模块
|
# 加载自定义模块
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
set(DEP_ROOT_DIR ${CMAKE_SOURCE_DIR}/3rdpart/external-${CMAKE_SYSTEM_NAME})
|
|
||||||
if(NOT EXISTS ${DEP_ROOT_DIR})
|
|
||||||
file(MAKE_DIRECTORY ${DEP_ROOT_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_program(CCACHE_FOUND ccache)
|
project(ZLMediaKit LANGUAGES C CXX)
|
||||||
if(CCACHE_FOUND)
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
|
||||||
endif(CCACHE_FOUND)
|
|
||||||
|
|
||||||
#add_compile_options(-D__STDC_FORMAT_MACROS)
|
# 使能 C++11
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
add_compile_options(-D__STDC_FORMAT_MACROS)
|
|
||||||
message(STATUS "-D__STDC_FORMAT_MACROS")
|
option(ENABLE_API "Enable C API SDK" ON)
|
||||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
option(ENABLE_API_STATIC_LIB "Enable mk_api static lib" OFF)
|
||||||
|
option(ENABLE_ASAN "Enable Address Sanitize" OFF)
|
||||||
|
option(ENABLE_CXX_API "Enable C++ API SDK" OFF)
|
||||||
|
option(ENABLE_FAAC "Enable FAAC" OFF)
|
||||||
|
option(ENABLE_FFMPEG "Enable FFmpeg" OFF)
|
||||||
|
option(ENABLE_HLS "Enable HLS" ON)
|
||||||
|
option(ENABLE_JEMALLOC_STATIC "Enable static linking to the jemalloc library" OFF)
|
||||||
|
option(ENABLE_MEM_DEBUG "Enable Memory Debug" OFF)
|
||||||
|
option(ENABLE_MP4 "Enable MP4" ON)
|
||||||
|
option(ENABLE_MSVC_MT "Enable MSVC Mt/Mtd lib" ON)
|
||||||
|
option(ENABLE_MYSQL "Enable MySQL" OFF)
|
||||||
|
option(ENABLE_OPENSSL "Enable OpenSSL" ON)
|
||||||
|
option(ENABLE_PLAYER "Enable Player" ON)
|
||||||
|
option(ENABLE_RTPPROXY "Enable RTPPROXY" ON)
|
||||||
|
option(ENABLE_SERVER "Enable Server" ON)
|
||||||
|
option(ENABLE_SERVER_LIB "Enable server as android static library" OFF)
|
||||||
|
option(ENABLE_SRT "Enable SRT" ON)
|
||||||
|
option(ENABLE_TESTS "Enable Tests" ON)
|
||||||
|
option(ENABLE_WEBRTC "Enable WebRTC" ON)
|
||||||
|
option(ENABLE_X264 "Enable x264" OFF)
|
||||||
|
|
||||||
|
option(USE_SOLUTION_FOLDERS "Enable solution dir supported" ON)
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
#set(CMAKE_BUILD_TYPE "Release")
|
|
||||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
set(CMAKE_BUILD_TYPE "Debug")
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "编译类型: ${CMAKE_BUILD_TYPE}")
|
message(STATUS "编译类型: ${CMAKE_BUILD_TYPE}")
|
||||||
|
|
||||||
#设置bin和lib库目录
|
# 方便排查编译问题, 需要 FORCE CACHE, 否则需要命令行设置才生效
|
||||||
set(RELEASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
|
set(CMAKE_VERBOSE_MAKEFILE ON CACHE INTERNAL "" FORCE)
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/linux/${CMAKE_BUILD_TYPE})
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/linux/${CMAKE_BUILD_TYPE})
|
# 安装路径
|
||||||
add_compile_options(-fPIC -Wall -Wno-unused-variable -Wno-unused-value)
|
if(NOT CMAKE_INSTALL_PREFIX)
|
||||||
INCLUDE(CheckCXXSourceCompiles)
|
if(UNIX)
|
||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/checks/atomic_check.cpp atomic_check_cpp)
|
set(INSTALL_PATH_LIB lib${LIB_SUFFIX})
|
||||||
CHECK_CXX_SOURCE_COMPILES("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITHOUT_LIB)
|
set(INSTALL_PATH_INCLUDE include)
|
||||||
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
|
set(INSTALL_PATH_RUNTIME bin)
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
|
elseif(WIN32)
|
||||||
CHECK_CXX_SOURCE_COMPILES("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITH_LIB)
|
# Windows 下安装到了用户主目录下?
|
||||||
if(NOT HAVE_CXX_ATOMICS_WITH_LIB)
|
set(INSTALL_PATH_LIB $ENV{HOME}/${CMAKE_PROJECT_NAME}/lib)
|
||||||
message(WARNING "Compiler doesn't support std::atomic<long long>")
|
set(INSTALL_PATH_INCLUDE $ENV{HOME}/${CMAKE_PROJECT_NAME}/include)
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")
|
message(WARNING "该平台(${CMAKE_SYSTEM_NAME})下暂未设置安装路径")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
||||||
if (CMAKE_CL_64)
|
|
||||||
set(CL_32_64 64)
|
|
||||||
else()
|
else()
|
||||||
set(CL_32_64 32)
|
set(INSTALL_PATH_LIB ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
|
||||||
endif ()
|
set(INSTALL_PATH_INCLUDE ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/windows${CL_32_64}/${CMAKE_BUILD_TYPE})
|
set(INSTALL_PATH_RUNTIME ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/windows${CL_32_64}/${CMAKE_BUILD_TYPE})
|
|
||||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
||||||
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/mac/${CMAKE_BUILD_TYPE})
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/mac/${CMAKE_BUILD_TYPE})
|
|
||||||
add_compile_options(-Wall -Wno-unused-variable -Wno-unused-value)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
|
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_LOWER)
|
||||||
|
# 设置输出目录, 包括 bin, lib 以及其他文件
|
||||||
|
# Windows 也不再区分 32/64
|
||||||
|
set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/release/${SYSTEM_NAME_LOWER}/${CMAKE_BUILD_TYPE})
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${OUTPUT_DIR})
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_DIR})
|
||||||
|
|
||||||
#设置工程源码根目录
|
# 添加 git 版本信息
|
||||||
set(ToolKit_Root ${CMAKE_CURRENT_SOURCE_DIR}/3rdpart/ZLToolKit/src)
|
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
|
||||||
set(MediaKit_Root ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
set(BRANCH_NAME "Git_NotFound_Unkown_branch")
|
||||||
set(MediaServer_Root ${CMAKE_CURRENT_SOURCE_DIR}/3rdpart/media-server)
|
set(BUILD_TIME "")
|
||||||
|
|
||||||
#设置头文件目录
|
string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M:%S")
|
||||||
INCLUDE_DIRECTORIES(${ToolKit_Root})
|
|
||||||
INCLUDE_DIRECTORIES(${MediaKit_Root})
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/3rdpart)
|
|
||||||
|
|
||||||
option(ENABLE_HLS "Enable HLS" true)
|
find_package(Git QUIET)
|
||||||
option(ENABLE_OPENSSL "Enable OpenSSL" true)
|
if(GIT_FOUND)
|
||||||
option(ENABLE_MYSQL "Enable MySQL" false)
|
execute_process(
|
||||||
option(ENABLE_FAAC "Enable FAAC" false)
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD
|
||||||
option(ENABLE_X264 "Enable x264" false)
|
OUTPUT_VARIABLE COMMIT_HASH
|
||||||
option(ENABLE_MP4 "Enable MP4" true)
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
option(ENABLE_RTPPROXY "Enable RTPPROXY" true)
|
ERROR_QUIET
|
||||||
option(ENABLE_API "Enable C API SDK" true)
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
option(ENABLE_CXX_API "Enable C++ API SDK" false)
|
execute_process(
|
||||||
option(ENABLE_TESTS "Enable Tests" true)
|
COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
|
||||||
option(ENABLE_SERVER "Enable Server" true)
|
OUTPUT_VARIABLE BRANCH_NAME
|
||||||
option(ENABLE_SERVER_LIB "Enable server as android static library" false)
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
option(ENABLE_MEM_DEBUG "Enable Memory Debug" false)
|
ERROR_QUIET
|
||||||
option(ENABLE_ASAN "Enable Address Sanitize" false)
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
option(ENABLE_WEBRTC "Enable WebRTC" true)
|
|
||||||
option(ENABLE_PLAYER "Enable Player" true)
|
|
||||||
option(ENABLE_FFMPEG "Enable FFmpeg" false)
|
|
||||||
option(ENABLE_MSVC_MT "Enable MSVC Mt/Mtd lib" true)
|
|
||||||
option(ENABLE_API_STATIC_LIB "Enable mk_api static lib" false)
|
|
||||||
option(USE_SOLUTION_FOLDERS "Enable solution dir supported" ON)
|
|
||||||
option(ENABLE_SRT "Enable SRT" true)
|
|
||||||
option(ENABLE_JEMALLOC_STATIC "Enable static linking to the jemalloc library" false)
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
# Solution folders:
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
if(USE_SOLUTION_FOLDERS)
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
||||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini
|
||||||
|
${CMAKE_BINARY_DIR}/version.h
|
||||||
|
@ONLY)
|
||||||
|
|
||||||
|
message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}:${BUILD_TIME}")
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# 方便修改全局变量
|
||||||
|
function(update_cached name value)
|
||||||
|
set("${name}" "${value}" CACHE INTERNAL "*** Internal ***" FORCE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(update_cached_list name)
|
||||||
|
set(_tmp_list "${${name}}")
|
||||||
|
list(APPEND _tmp_list "${ARGN}")
|
||||||
|
list(REMOVE_DUPLICATES _tmp_list)
|
||||||
|
update_cached(${name} "${_tmp_list}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# TODO:
|
||||||
function(set_file_group prefix)
|
function(set_file_group prefix)
|
||||||
message(STATUS "set_file_group " ${prefix} " " ${ARGC})
|
message(STATUS "set_file_group " ${prefix} " " ${ARGC})
|
||||||
foreach(FILE IN LISTS ARGN 1)
|
foreach(FILE IN LISTS ARGN 1)
|
||||||
@ -133,90 +151,41 @@ function(set_file_group prefix)
|
|||||||
# Make sure we are using windows slashes
|
# Make sure we are using windows slashes
|
||||||
string(REPLACE "/" "\\" GROUP "${GROUP}")
|
string(REPLACE "/" "\\" GROUP "${GROUP}")
|
||||||
|
|
||||||
# Group into "Source Files" and "Header Files"
|
|
||||||
#if ("${FILE}" MATCHES ".*\\.cpp")
|
|
||||||
# set(GROUP "Source Files${GROUP}")
|
|
||||||
#elseif("${FILE}" MATCHES ".*\\.h")
|
|
||||||
# set(GROUP "Header Files${GROUP}")
|
|
||||||
#endif()
|
|
||||||
#message(STATUS ${GROUP} " : " ${FILE})
|
|
||||||
source_group("${GROUP}" FILES "${FILE}")
|
source_group("${GROUP}" FILES "${FILE}")
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if (MSVC AND ENABLE_MSVC_MT)
|
|
||||||
set(CompilerFlags
|
find_program(CCACHE_FOUND ccache)
|
||||||
CMAKE_CXX_FLAGS
|
if(CCACHE_FOUND)
|
||||||
CMAKE_CXX_FLAGS_DEBUG
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||||
CMAKE_CXX_FLAGS_RELEASE
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||||
CMAKE_C_FLAGS
|
|
||||||
CMAKE_C_FLAGS_DEBUG
|
|
||||||
CMAKE_C_FLAGS_RELEASE
|
|
||||||
)
|
|
||||||
foreach(CompilerFlag ${CompilerFlags})
|
|
||||||
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
|
||||||
endforeach()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 添加git版本信息
|
if(UNIX)
|
||||||
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
|
# UNIX/Linux/Darwin
|
||||||
set(BRANCH_NAME "Git_NotFound_Unkown_branch")
|
set(COMPILE_OPTIONS_DEFAULT
|
||||||
set(BUILD_TIME "")
|
"-fPIC"
|
||||||
|
"-Wall;-Wextra"
|
||||||
string(TIMESTAMP BUILD_TIME "%Y/%m/%d-%H:%M:%S")
|
"-Wno-unused-function;-Wno-unused-parameter;-Wno-unused-variable"
|
||||||
|
"-Wno-error=extra;-Wno-error=missing-field-initializers;-Wno-error=type-limits")
|
||||||
find_package(Git QUIET)
|
elseif(WIN32)
|
||||||
if (GIT_FOUND)
|
# TODO: /wd4819 应该是不会生效
|
||||||
execute_process(
|
set(COMPILE_OPTIONS_DEFAULT "/wd4819")
|
||||||
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%h
|
|
||||||
OUTPUT_VARIABLE COMMIT_HASH
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
ERROR_QUIET
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
|
|
||||||
OUTPUT_VARIABLE BRANCH_NAME
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
ERROR_QUIET
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file(
|
# mediakit 以及各个 runtime 依赖
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini
|
update_cached_list(MK_LINK_LIBRARIES "")
|
||||||
${CMAKE_BINARY_DIR}/version.h
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_VERSION)
|
||||||
@ONLY
|
|
||||||
)
|
|
||||||
|
|
||||||
add_definitions(-DENABLE_VERSION)
|
|
||||||
include_directories(${CMAKE_BINARY_DIR})
|
|
||||||
message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}:${BUILD_TIME}")
|
|
||||||
|
|
||||||
if (ENABLE_MEM_DEBUG)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-wrap,free -Wl,-wrap,malloc -Wl,-wrap,realloc -Wl,-wrap,calloc")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-wrap,free -Wl,-wrap,malloc -Wl,-wrap,realloc -Wl,-wrap,calloc")
|
|
||||||
add_definitions(-DENABLE_MEM_DEBUG)
|
|
||||||
message(STATUS "已启用内存调试功能")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (ENABLE_ASAN)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
||||||
message(STATUS "已启用Address Sanitize")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(LINK_LIB_LIST zlmediakit zltoolkit)
|
|
||||||
|
|
||||||
|
# 多个模块依赖 ffmpeg 相关库, 统一查找
|
||||||
if(ENABLE_FFMPEG)
|
if(ENABLE_FFMPEG)
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
# 查找 ffmpeg/libutil 是否安装
|
# 查找 ffmpeg/libutil 是否安装
|
||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
pkg_check_modules(AVUTIL QUIET IMPORTED_TARGET libavutil)
|
pkg_check_modules(AVUTIL QUIET IMPORTED_TARGET libavutil)
|
||||||
if(AVUTIL_FOUND)
|
if(AVUTIL_FOUND)
|
||||||
include_directories(${AVUTIL_INCLUDE_DIRS})
|
update_cached_list(MK_LINK_LIBRARIES PkgConfig::AVUTIL)
|
||||||
link_directories(${AVUTIL_LIBRARY_DIRS})
|
|
||||||
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
|
|
||||||
message(STATUS "found library: ${AVUTIL_LIBRARIES}")
|
message(STATUS "found library: ${AVUTIL_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -225,9 +194,7 @@ if (ENABLE_FFMPEG)
|
|||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
pkg_check_modules(AVCODEC QUIET IMPORTED_TARGET libavcodec)
|
pkg_check_modules(AVCODEC QUIET IMPORTED_TARGET libavcodec)
|
||||||
if(AVCODEC_FOUND)
|
if(AVCODEC_FOUND)
|
||||||
include_directories(${AVCODEC_INCLUDE_DIRS})
|
update_cached_list(MK_LINK_LIBRARIES PkgConfig::AVCODEC)
|
||||||
link_directories(${AVCODEC_LIBRARY_DIRS})
|
|
||||||
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
|
|
||||||
message(STATUS "found library: ${AVCODEC_LIBRARIES}")
|
message(STATUS "found library: ${AVCODEC_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -236,9 +203,7 @@ if (ENABLE_FFMPEG)
|
|||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
pkg_check_modules(SWSCALE QUIET IMPORTED_TARGET libswscale)
|
pkg_check_modules(SWSCALE QUIET IMPORTED_TARGET libswscale)
|
||||||
if(SWSCALE_FOUND)
|
if(SWSCALE_FOUND)
|
||||||
include_directories(${SWSCALE_INCLUDE_DIRS})
|
update_cached_list(MK_LINK_LIBRARIES PkgConfig::SWSCALE)
|
||||||
link_directories(${SWSCALE_LIBRARY_DIRS})
|
|
||||||
list(APPEND LINK_LIB_LIST ${SWSCALE_LIBRARIES})
|
|
||||||
message(STATUS "found library: ${SWSCALE_LIBRARIES}")
|
message(STATUS "found library: ${SWSCALE_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -247,9 +212,7 @@ if (ENABLE_FFMPEG)
|
|||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
pkg_check_modules(SWRESAMPLE QUIET IMPORTED_TARGET libswresample)
|
pkg_check_modules(SWRESAMPLE QUIET IMPORTED_TARGET libswresample)
|
||||||
if(SWRESAMPLE_FOUND)
|
if(SWRESAMPLE_FOUND)
|
||||||
include_directories(${SWRESAMPLE_INCLUDE_DIRS})
|
update_cached_list(MK_LINK_LIBRARIES PkgConfig::SWRESAMPLE)
|
||||||
link_directories(${SWRESAMPLE_LIBRARY_DIRS})
|
|
||||||
list(APPEND LINK_LIB_LIST ${SWRESAMPLE_LIBRARIES})
|
|
||||||
message(STATUS "found library: ${SWRESAMPLE_LIBRARIES}")
|
message(STATUS "found library: ${SWRESAMPLE_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -258,8 +221,8 @@ if (ENABLE_FFMPEG)
|
|||||||
if(NOT AVUTIL_FOUND)
|
if(NOT AVUTIL_FOUND)
|
||||||
find_package(AVUTIL QUIET)
|
find_package(AVUTIL QUIET)
|
||||||
if(AVUTIL_FOUND)
|
if(AVUTIL_FOUND)
|
||||||
include_directories(${AVUTIL_INCLUDE_DIR})
|
include_directories(SYSTEM ${AVUTIL_INCLUDE_DIR})
|
||||||
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${AVUTIL_LIBRARIES})
|
||||||
message(STATUS "found library: ${AVUTIL_LIBRARIES}")
|
message(STATUS "found library: ${AVUTIL_LIBRARIES}")
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
@ -268,8 +231,8 @@ if (ENABLE_FFMPEG)
|
|||||||
if(NOT AVCODEC_FOUND)
|
if(NOT AVCODEC_FOUND)
|
||||||
find_package(AVCODEC QUIET)
|
find_package(AVCODEC QUIET)
|
||||||
if(AVCODEC_FOUND)
|
if(AVCODEC_FOUND)
|
||||||
include_directories(${AVCODEC_INCLUDE_DIR})
|
include_directories(SYSTEM ${AVCODEC_INCLUDE_DIR})
|
||||||
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${AVCODEC_LIBRARIES})
|
||||||
message(STATUS "found library: ${AVCODEC_LIBRARIES}")
|
message(STATUS "found library: ${AVCODEC_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -278,8 +241,8 @@ if (ENABLE_FFMPEG)
|
|||||||
if(NOT SWSCALE_FOUND)
|
if(NOT SWSCALE_FOUND)
|
||||||
find_package(SWSCALE QUIET)
|
find_package(SWSCALE QUIET)
|
||||||
if(SWSCALE_FOUND)
|
if(SWSCALE_FOUND)
|
||||||
include_directories(${SWSCALE_INCLUDE_DIR})
|
include_directories(SYSTEM ${SWSCALE_INCLUDE_DIR})
|
||||||
list(APPEND LINK_LIB_LIST ${SWSCALE_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${SWSCALE_LIBRARIES})
|
||||||
message(STATUS "found library: ${SWSCALE_LIBRARIES}")
|
message(STATUS "found library: ${SWSCALE_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -288,35 +251,54 @@ if (ENABLE_FFMPEG)
|
|||||||
if(NOT SWRESAMPLE_FOUND)
|
if(NOT SWRESAMPLE_FOUND)
|
||||||
find_package(SWRESAMPLE QUIET)
|
find_package(SWRESAMPLE QUIET)
|
||||||
if(SWRESAMPLE_FOUND)
|
if(SWRESAMPLE_FOUND)
|
||||||
include_directories(${SWRESAMPLE_INCLUDE_DIRS})
|
include_directories(SYSTEM ${SWRESAMPLE_INCLUDE_DIRS})
|
||||||
list(APPEND LINK_LIB_LIST ${SWRESAMPLE_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${SWRESAMPLE_LIBRARIES})
|
||||||
message(STATUS "found library: ${SWRESAMPLE_LIBRARIES}")
|
message(STATUS "found library: ${SWRESAMPLE_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(AVUTIL_FOUND AND AVCODEC_FOUND AND SWSCALE_FOUND AND SWRESAMPLE_FOUND)
|
if(AVUTIL_FOUND AND AVCODEC_FOUND AND SWSCALE_FOUND AND SWRESAMPLE_FOUND)
|
||||||
add_definitions(-DENABLE_FFMPEG)
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_FFMPEG)
|
||||||
list(APPEND LINK_LIB_LIST ${CMAKE_DL_LIBS})
|
update_cached_list(MK_LINK_LIBRARIES ${CMAKE_DL_LIBS})
|
||||||
else()
|
else()
|
||||||
set(ENABLE_FFMPEG off)
|
set(ENABLE_FFMPEG OFF)
|
||||||
message(WARNING "ffmpeg 相关功能未找到")
|
message(WARNING "ffmpeg 相关功能未找到")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_MEM_DEBUG)
|
||||||
|
list(APPEND COMPILE_OPTIONS_DEFAULT
|
||||||
|
"-Wl,-wrap,free;-Wl,-wrap,malloc;-Wl,-wrap,realloc;-Wl,-wrap,calloc")
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_MEM_DEBUG)
|
||||||
|
message(STATUS "已启用内存调试功能")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_ASAN)
|
||||||
|
list(APPEND COMPILE_OPTIONS_DEFAULT
|
||||||
|
"-fsanitize=address;-fno-omit-frame-pointer")
|
||||||
|
message(STATUS "已启用 Address Sanitize")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# TODO: 下载静态编译 jemalloc 后静态编译链接?
|
||||||
|
set(DEP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdpart/external-${CMAKE_SYSTEM_NAME})
|
||||||
if(ENABLE_JEMALLOC_STATIC)
|
if(ENABLE_JEMALLOC_STATIC)
|
||||||
include(cmake/Jemalloc.cmake)
|
if(NOT EXISTS ${DEP_ROOT_DIR})
|
||||||
include_directories(${DEP_ROOT_DIR}/${JEMALLOC_NAME}/include/jemalloc)
|
file(MAKE_DIRECTORY ${DEP_ROOT_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(Jemalloc)
|
||||||
|
include_directories(SYSTEM ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/include/jemalloc)
|
||||||
link_directories(${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib)
|
link_directories(${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib)
|
||||||
|
# 用于影响后续查找过程
|
||||||
set(JEMALLOC_ROOT_DIR "${DEP_ROOT_DIR}/${JEMALLOC_NAME}")
|
set(JEMALLOC_ROOT_DIR "${DEP_ROOT_DIR}/${JEMALLOC_NAME}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 默认链接 jemalloc 库避免内存碎片
|
# 默认链接 jemalloc 库避免内存碎片
|
||||||
find_package(JEMALLOC QUIET)
|
find_package(JEMALLOC QUIET)
|
||||||
if(JEMALLOC_FOUND)
|
if(JEMALLOC_FOUND)
|
||||||
message(STATUS "found library:\"${JEMALLOC_LIBRARIES}\"")
|
message(STATUS "found library: ${JEMALLOC_LIBRARIES}")
|
||||||
include_directories(${JEMALLOC_INCLUDE_DIR})
|
include_directories(${JEMALLOC_INCLUDE_DIR})
|
||||||
list(APPEND LINK_LIB_LIST ${JEMALLOC_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 查找 openssl 是否安装
|
# 查找 openssl 是否安装
|
||||||
@ -324,217 +306,126 @@ find_package(OpenSSL QUIET)
|
|||||||
if(OPENSSL_FOUND AND ENABLE_OPENSSL)
|
if(OPENSSL_FOUND AND ENABLE_OPENSSL)
|
||||||
message(STATUS "found library: ${OPENSSL_LIBRARIES}, ENABLE_OPENSSL defined")
|
message(STATUS "found library: ${OPENSSL_LIBRARIES}, ENABLE_OPENSSL defined")
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||||
add_definitions(-DENABLE_OPENSSL)
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_OPENSSL)
|
||||||
list(APPEND LINK_LIB_LIST ${OPENSSL_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${OPENSSL_LIBRARIES})
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND OPENSSL_USE_STATIC_LIBS)
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND OPENSSL_USE_STATIC_LIBS)
|
||||||
list(APPEND LINK_LIB_LIST dl)
|
update_cached_list(MK_LINK_LIBRARIES ${CMAKE_DL_LIBS})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(ENABLE_OPENSSL off)
|
set(ENABLE_OPENSSL OFF)
|
||||||
message(WARNING "openssl未找到,rtmp将不支持flash播放器,https/wss/rtsps/rtmps也将失效")
|
message(WARNING "openssl 未找到, rtmp 将不支持 flash 播放器, https/wss/rtsps/rtmps 也将失效")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 查找 mysql 是否安装
|
# 查找 mysql 是否安装
|
||||||
find_package(MYSQL QUIET)
|
find_package(MYSQL QUIET)
|
||||||
if(MYSQL_FOUND AND ENABLE_MYSQL)
|
if(MYSQL_FOUND AND ENABLE_MYSQL)
|
||||||
message(STATUS "found library: ${MYSQL_LIBRARIES}, ENABLE_MYSQL defined")
|
message(STATUS "found library: ${MYSQL_LIBRARIES}, ENABLE_MYSQL defined")
|
||||||
include_directories(${MYSQL_INCLUDE_DIR})
|
include_directories(SYSTEM
|
||||||
include_directories(${MYSQL_INCLUDE_DIR}/mysql)
|
${MYSQL_INCLUDE_DIR}
|
||||||
add_definitions(-DENABLE_MYSQL)
|
${MYSQL_INCLUDE_DIR}/mysql)
|
||||||
list(APPEND LINK_LIB_LIST ${MYSQL_LIBRARIES})
|
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_MYSQL)
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES ${MYSQL_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 查找 x264 是否安装
|
# 查找 x264 是否安装
|
||||||
find_package(X264 QUIET)
|
find_package(X264 QUIET)
|
||||||
if(X264_FOUND AND ENABLE_X264)
|
if(X264_FOUND AND ENABLE_X264)
|
||||||
message(STATUS "found library: ${X264_LIBRARIES}, ENABLE_X264 defined")
|
message(STATUS "found library: ${X264_LIBRARIES}, ENABLE_X264 defined")
|
||||||
include_directories(${X264_INCLUDE_DIRS})
|
include_directories(SYSTEM ${X264_INCLUDE_DIRS})
|
||||||
add_definitions(-DENABLE_X264)
|
|
||||||
list(APPEND LINK_LIB_LIST ${X264_LIBRARIES})
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_X264)
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES ${X264_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 查找 faac 是否安装
|
# 查找 faac 是否安装
|
||||||
find_package(FAAC QUIET)
|
find_package(FAAC QUIET)
|
||||||
if(FAAC_FOUND AND ENABLE_FAAC)
|
if(FAAC_FOUND AND ENABLE_FAAC)
|
||||||
message(STATUS "found library:${FAAC_LIBRARIES}, ENABLE_FAAC defined")
|
message(STATUS "found library:${FAAC_LIBRARIES}, ENABLE_FAAC defined")
|
||||||
include_directories(${FAAC_INCLUDE_DIR})
|
include_directories(SYSTEM ${FAAC_INCLUDE_DIR})
|
||||||
add_definitions(-DENABLE_FAAC)
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_FAAC)
|
||||||
list(APPEND LINK_LIB_LIST ${FAAC_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${FAAC_LIBRARIES})
|
||||||
endif ()
|
|
||||||
|
|
||||||
#set(VS_FALGS "/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573 /wd4996" )
|
|
||||||
set(VS_FALGS "/wd4819")
|
|
||||||
|
|
||||||
#添加mpeg用于支持ts生成
|
|
||||||
if (ENABLE_RTPPROXY OR ENABLE_HLS)
|
|
||||||
include_directories(${MediaServer_Root}/libmpeg/include)
|
|
||||||
aux_source_directory(${MediaServer_Root}/libmpeg/include src_mpeg)
|
|
||||||
aux_source_directory(${MediaServer_Root}/libmpeg/source src_mpeg)
|
|
||||||
|
|
||||||
add_library(mpeg STATIC ${src_mpeg})
|
|
||||||
list(APPEND LINK_LIB_LIST mpeg)
|
|
||||||
list(APPEND CXX_API_TARGETS mpeg)
|
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#添加mov、flv库用于MP4录制
|
|
||||||
if (ENABLE_MP4)
|
|
||||||
message(STATUS "ENABLE_MP4 defined")
|
|
||||||
add_definitions(-DENABLE_MP4)
|
|
||||||
|
|
||||||
include_directories(${MediaServer_Root}/libmov/include)
|
|
||||||
include_directories(${MediaServer_Root}/libflv/include)
|
|
||||||
|
|
||||||
aux_source_directory(${MediaServer_Root}/libmov/include src_mov)
|
|
||||||
aux_source_directory(${MediaServer_Root}/libmov/source src_mov)
|
|
||||||
|
|
||||||
aux_source_directory(${MediaServer_Root}/libflv/include src_flv)
|
|
||||||
aux_source_directory(${MediaServer_Root}/libflv/source src_flv)
|
|
||||||
|
|
||||||
add_library(mov STATIC ${src_mov})
|
|
||||||
add_library(flv STATIC ${src_flv})
|
|
||||||
list(APPEND LINK_LIB_LIST mov flv)
|
|
||||||
list(APPEND CXX_API_TARGETS mov flv)
|
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
set_target_properties(mov flv PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (ENABLE_RTPPROXY)
|
|
||||||
message(STATUS "ENABLE_RTPPROXY defined")
|
|
||||||
add_definitions(-DENABLE_RTPPROXY)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (ENABLE_HLS)
|
|
||||||
message(STATUS "ENABLE_HLS defined")
|
|
||||||
add_definitions(-DENABLE_HLS)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#收集源代码
|
|
||||||
file(GLOB ToolKit_src_list ${ToolKit_Root}/*/*.cpp ${ToolKit_Root}/*/*.h ${ToolKit_Root}/*/*.c)
|
|
||||||
if (IOS)
|
|
||||||
list(APPEND ToolKit_src_list ${ToolKit_Root}/Network/Socket_ios.mm)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
file(GLOB MediaKit_src_list ${MediaKit_Root}/*/*.cpp ${MediaKit_Root}/*/*.h ${MediaKit_Root}/*/*.c)
|
|
||||||
|
|
||||||
#去除win32的适配代码
|
|
||||||
if (NOT WIN32)
|
|
||||||
list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c)
|
|
||||||
else ()
|
|
||||||
#防止Windows.h包含Winsock.h
|
|
||||||
add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (USE_SOLUTION_FOLDERS AND (NOT GROUP_BY_EXPLORER)) # 在 IDE 中对文件进行分组,源文件和头文件分开
|
|
||||||
set_file_group(${ToolKit_Root} ${ToolKit_src_list})
|
|
||||||
set_file_group("${CMAKE_CURRENT_SOURCE_DIR}/src" ${MediaKit_src_list})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#添加库
|
|
||||||
add_library(zltoolkit STATIC ${ToolKit_src_list})
|
|
||||||
add_library(zlmediakit STATIC ${MediaKit_src_list})
|
|
||||||
list(APPEND CXX_API_TARGETS zltoolkit zlmediakit)
|
|
||||||
|
|
||||||
#安装目录
|
|
||||||
if (WIN32)
|
|
||||||
set(INSTALL_PATH_LIB $ENV{HOME}/${CMAKE_PROJECT_NAME}/lib)
|
|
||||||
set(INSTALL_PATH_INCLUDE $ENV{HOME}/${CMAKE_PROJECT_NAME}/include)
|
|
||||||
else ()
|
|
||||||
set(INSTALL_PATH_LIB lib${LIB_SUFFIX})
|
|
||||||
set(INSTALL_PATH_INCLUDE include)
|
|
||||||
set(INSTALL_PATH_EXECUTABLE bin)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (ENABLE_CXX_API)
|
|
||||||
# 保留目录结构
|
|
||||||
install(DIRECTORY ${ToolKit_Root}/ DESTINATION ${INSTALL_PATH_INCLUDE}/ZLToolKit REGEX "(.*[.](md|cpp)|win32)$" EXCLUDE)
|
|
||||||
install(DIRECTORY ${MediaKit_Root}/ DESTINATION ${INSTALL_PATH_INCLUDE}/ZLMediaKit REGEX ".*[.](md|cpp)$" EXCLUDE)
|
|
||||||
install(TARGETS ${CXX_API_TARGETS} DESTINATION ${INSTALL_PATH_LIB})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
|
update_cached_list(MK_LINK_LIBRARIES WS2_32 Iphlpapi shlwapi)
|
||||||
if (MSVC)
|
|
||||||
set_target_properties(zltoolkit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
|
||||||
set_target_properties(zlmediakit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
|
||||||
endif ()
|
|
||||||
elseif(NOT ANDROID OR IOS)
|
elseif(NOT ANDROID OR IOS)
|
||||||
list(APPEND LINK_LIB_LIST pthread)
|
update_cached_list(MK_LINK_LIBRARIES pthread)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#复制文件过来
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/www" DESTINATION ${EXECUTABLE_OUTPUT_PATH})
|
include(CheckCXXSourceCompiles)
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf/config.ini" DESTINATION ${EXECUTABLE_OUTPUT_PATH})
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/checks/atomic_check.cpp atomic_check_cpp)
|
||||||
|
check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITHOUT_LIB)
|
||||||
|
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
|
||||||
if (ENABLE_WEBRTC)
|
# cmake --help-policy CMP0075
|
||||||
#查找srtp是否安装
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
|
||||||
find_package(SRTP QUIET)
|
check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITH_LIB)
|
||||||
if (SRTP_FOUND AND ENABLE_OPENSSL)
|
if(NOT HAVE_CXX_ATOMICS_WITH_LIB)
|
||||||
message(STATUS "found library:${SRTP_LIBRARIES}")
|
message(WARNING "Compiler doesn't support std::atomic<long long>")
|
||||||
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)
|
|
||||||
message(STATUS "webrtc功能已开启")
|
|
||||||
|
|
||||||
find_package(SCTP QUIET)
|
|
||||||
if (SCTP_FOUND)
|
|
||||||
message(STATUS "found library:${SCTP_INCLUDE_DIRS} ${SCTP_LIBRARIES}")
|
|
||||||
include_directories(${SCTP_INCLUDE_DIRS})
|
|
||||||
list(APPEND LINK_LIB_LIST ${SCTP_LIBRARIES})
|
|
||||||
add_definitions(-DENABLE_SCTP)
|
|
||||||
message(STATUS "webrtc datachannel功能已打开")
|
|
||||||
endif ()
|
|
||||||
else()
|
else()
|
||||||
set(ENABLE_WEBRTC off)
|
update_cached_list(MK_LINK_LIBRARIES atomic)
|
||||||
message(WARNING "srtp未找到, webrtc相关功能打开失败")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Solution folders:
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
if(USE_SOLUTION_FOLDERS)
|
||||||
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC AND ENABLE_MSVC_MT)
|
||||||
|
set(CompilerFlags
|
||||||
|
CMAKE_CXX_FLAGS
|
||||||
|
CMAKE_CXX_FLAGS_DEBUG
|
||||||
|
CMAKE_CXX_FLAGS_RELEASE
|
||||||
|
CMAKE_C_FLAGS
|
||||||
|
CMAKE_C_FLAGS_DEBUG
|
||||||
|
CMAKE_C_FLAGS_RELEASE)
|
||||||
|
# TODO: 通常应该不需要替换
|
||||||
|
foreach(CompilerFlag ${CompilerFlags})
|
||||||
|
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# for version.h
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
add_subdirectory(3rdpart)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
if(ENABLE_SRT)
|
if(ENABLE_SRT)
|
||||||
add_definitions(-DENABLE_SRT)
|
add_subdirectory(srt)
|
||||||
include_directories(./srt)
|
endif()
|
||||||
file(GLOB SRC_SRT_LIST ./srt/*.cpp ./srt/*.h ./srt/*.hpp)
|
|
||||||
add_library(srt ${SRC_SRT_LIST})
|
if(ENABLE_WEBRTC)
|
||||||
list(APPEND LINK_LIB_LIST srt)
|
add_subdirectory(webrtc)
|
||||||
message(STATUS "srt 功能已开启")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#添加c库
|
|
||||||
if(ENABLE_API)
|
if(ENABLE_API)
|
||||||
add_subdirectory(api)
|
add_subdirectory(api)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#ios不编译可执行程序
|
# IOS 不编译可执行程序
|
||||||
if (IOS)
|
if(NOT IOS)
|
||||||
return()
|
if(ENABLE_PLAYER AND ENABLE_FFMPEG)
|
||||||
endif()
|
|
||||||
|
|
||||||
#测试程序
|
|
||||||
if (ENABLE_TESTS)
|
|
||||||
add_subdirectory(tests)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#主服务器
|
|
||||||
if (ENABLE_SERVER)
|
|
||||||
add_subdirectory(server)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#播放器
|
|
||||||
if (ENABLE_PLAYER)
|
|
||||||
add_subdirectory(player)
|
add_subdirectory(player)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_SERVER_LIB)
|
add_subdirectory(server)
|
||||||
set(LINK_LIB_LIST ${LINK_LIB_LIST} PARENT_SCOPE)
|
# 复制文件过来
|
||||||
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/www"
|
||||||
|
DESTINATION ${EXECUTABLE_OUTPUT_PATH})
|
||||||
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf/config.ini"
|
||||||
|
DESTINATION ${EXECUTABLE_OUTPUT_PATH})
|
||||||
|
|
||||||
|
if(ENABLE_TESTS)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,38 +1,78 @@
|
|||||||
include_directories(include source)
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
file(GLOB api_src_list include/*.h source/*.cpp source/*.h source/*.c)
|
file(GLOB API_SRC_LIST
|
||||||
|
include/*.h
|
||||||
|
source/*.c
|
||||||
|
source/*.cpp
|
||||||
|
source/*.h)
|
||||||
|
|
||||||
|
set(LINK_LIBRARIES ${MK_LINK_LIBRARIES} jsoncpp)
|
||||||
|
|
||||||
if(IOS)
|
if(IOS)
|
||||||
add_library(mk_api STATIC ${api_src_list})
|
add_library(mk_api STATIC ${API_SRC_LIST})
|
||||||
target_link_libraries(mk_api ${LINK_LIB_LIST} jsoncpp)
|
target_link_libraries(mk_api
|
||||||
|
PRIVATE ${LINK_LIBRARIES})
|
||||||
return()
|
return()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_definitions(-DGENERATE_EXPORT)
|
set(COMPILE_DEFINITIONS ${MK_COMPILE_DEFINITIONS})
|
||||||
include_directories(${CMAKE_BINARY_DIR})
|
list(APPEND COMPILE_DEFINITIONS GENERATE_EXPORT)
|
||||||
|
|
||||||
if(ENABLE_API_STATIC_LIB)
|
if(ENABLE_API_STATIC_LIB)
|
||||||
add_definitions(-DMediaKitApi_STATIC)
|
add_library(mk_api STATIC ${API_SRC_LIST})
|
||||||
add_library(mk_api STATIC ${api_src_list})
|
list(APPEND COMPILE_DEFINITIONS MediaKitApi_STATIC)
|
||||||
else()
|
else()
|
||||||
add_library(mk_api SHARED ${api_src_list})
|
add_library(mk_api SHARED ${API_SRC_LIST})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_compile_definitions(mk_api
|
||||||
|
PRIVATE ${COMPILE_DEFINITIONS})
|
||||||
|
target_include_directories(mk_api
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
target_link_libraries(mk_api -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group)
|
target_link_libraries(mk_api -Wl,--start-group ${LINK_LIBRARIES} -Wl,--end-group)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(mk_api jsoncpp ${LINK_LIB_LIST})
|
target_link_libraries(mk_api jsoncpp ${LINK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
generate_export_header(mk_api
|
generate_export_header(mk_api
|
||||||
EXPORT_MACRO_NAME API_EXPORT
|
EXPORT_MACRO_NAME API_EXPORT
|
||||||
BASE_NAME MK_API
|
BASE_NAME MK_API
|
||||||
STATIC_DEFINE MediaKitApi_STATIC
|
STATIC_DEFINE MediaKitApi_STATIC
|
||||||
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/mk_export.h"
|
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/mk_export.h")
|
||||||
)
|
|
||||||
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|
||||||
file(GLOB api_header_list include/*.h ${CMAKE_BINARY_DIR}/*.h)
|
file(GLOB API_HEADER_LIST include/*.h ${CMAKE_CURRENT_BINARY_DIR}/*.h)
|
||||||
install(FILES ${api_header_list} DESTINATION ${INSTALL_PATH_INCLUDE})
|
install(FILES ${API_HEADER_LIST}
|
||||||
install(TARGETS mk_api ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB})
|
DESTINATION ${INSTALL_PATH_INCLUDE})
|
||||||
|
install(TARGETS mk_api
|
||||||
|
ARCHIVE DESTINATION ${INSTALL_PATH_LIB}
|
||||||
|
LIBRARY DESTINATION ${INSTALL_PATH_LIB})
|
||||||
|
@ -1,8 +1,30 @@
|
|||||||
aux_source_directory(. TEST_SRC_LIST)
|
# MIT License
|
||||||
include_directories(${PROJECT_BINARY_DIR}/api)
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} TEST_SRC_LIST)
|
||||||
|
|
||||||
foreach(TEST_SRC ${TEST_SRC_LIST})
|
foreach(TEST_SRC ${TEST_SRC_LIST})
|
||||||
STRING(REGEX REPLACE "^\\./|\\.c[a-zA-Z0-9_]*$" "" TEST_EXE_NAME ${TEST_SRC})
|
get_filename_component(TEST_EXE_NAME ${TEST_SRC} NAME_WE)
|
||||||
|
|
||||||
if(NOT ENABLE_FFMPEG)
|
if(NOT ENABLE_FFMPEG)
|
||||||
# 过滤掉依赖 FFmpeg 的测试模块
|
# 过滤掉依赖 FFmpeg 的测试模块
|
||||||
@ -15,14 +37,11 @@ foreach(TEST_SRC ${TEST_SRC_LIST})
|
|||||||
set(exe_name api_tester_${TEST_EXE_NAME})
|
set(exe_name api_tester_${TEST_EXE_NAME})
|
||||||
add_executable(${exe_name} ${TEST_SRC})
|
add_executable(${exe_name} ${TEST_SRC})
|
||||||
if(USE_SOLUTION_FOLDERS)
|
if(USE_SOLUTION_FOLDERS)
|
||||||
SET_PROPERTY(TARGET ${exe_name} PROPERTY FOLDER "api_test")
|
set_property(TARGET ${exe_name} PROPERTY FOLDER "api_test")
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
set_target_properties(${exe_name} PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${exe_name} mk_api)
|
target_link_libraries(${exe_name} mk_api)
|
||||||
|
target_compile_options(${exe_name} PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,31 +1,50 @@
|
|||||||
if (NOT ENABLE_FFMPEG)
|
# MIT License
|
||||||
return()
|
#
|
||||||
endif ()
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
set(LINK_LIBRARIES ${MK_LINK_LIBRARIES})
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
# 查找 SDL2 是否安装
|
# 查找 SDL2 是否安装
|
||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
pkg_check_modules(SDL2 QUIET IMPORTED_TARGET sdl2)
|
pkg_check_modules(SDL2 QUIET IMPORTED_TARGET sdl2)
|
||||||
if(SDL2_FOUND)
|
if(SDL2_FOUND)
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
list(APPEND LINK_LIBRARIES PkgConfig::SDL2)
|
||||||
link_directories(${SDL2_LIBRARY_DIRS})
|
|
||||||
list(APPEND LINK_LIB_LIST ${SDL2_LIBRARIES})
|
|
||||||
message(STATUS "found library: ${SDL2_LIBRARIES}")
|
message(STATUS "found library: ${SDL2_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
find_package(SDL2 QUIET)
|
find_package(SDL2 QUIET)
|
||||||
if(SDL2_FOUND)
|
if(SDL2_FOUND)
|
||||||
include_directories(${SDL2_INCLUDE_DIR})
|
include_directories(SYSTEM ${SDL2_INCLUDE_DIR})
|
||||||
list(APPEND LINK_LIB_LIST ${SDL2_LIBRARY})
|
list(APPEND LINK_LIBRARIES ${SDL2_LIBRARY})
|
||||||
message(STATUS "found library: ${SDL2_LIBRARY}")
|
message(STATUS "found library: ${SDL2_LIBRARY}")
|
||||||
endif (SDL2_FOUND)
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(PLAYER_NAME "test_player")
|
set(PLAYER_NAME "test_player")
|
||||||
|
|
||||||
# 如果 ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译播放器
|
# 如果 ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译播放器
|
||||||
if(NOT SDL2_FOUND)
|
if(NOT SDL2_FOUND)
|
||||||
message(STATUS "${PLAYER_NAME} disabled, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil ffmpeg/libswresample")
|
message(WARNING "${PLAYER_NAME} disabled, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil ffmpeg/libswresample")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -33,14 +52,18 @@ message(STATUS "${PLAYER_NAME} enabled")
|
|||||||
|
|
||||||
aux_source_directory(. SRC_LIST)
|
aux_source_directory(. SRC_LIST)
|
||||||
add_executable(${PLAYER_NAME} ${SRC_LIST})
|
add_executable(${PLAYER_NAME} ${SRC_LIST})
|
||||||
|
target_compile_definitions(${PLAYER_NAME}
|
||||||
|
PRIVATE ${MK_COMPILE_DEFINITIONS})
|
||||||
|
target_compile_options(${PLAYER_NAME}
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
|
||||||
|
# TODO: 统一参数?
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_target_properties(${PLAYER_NAME} PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
|
||||||
set_target_properties(${PLAYER_NAME} PROPERTIES LINK_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS")
|
set_target_properties(${PLAYER_NAME} PROPERTIES LINK_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
target_link_libraries(${PLAYER_NAME} -Wl,--start-group ${LINK_LIB_LIST} -Wl,--end-group)
|
target_link_libraries(${PLAYER_NAME} -Wl,--start-group ${LINK_LIBRARIES} -Wl,--end-group)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${PLAYER_NAME} ${LINK_LIB_LIST})
|
target_link_libraries(${PLAYER_NAME} ${LINK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,26 +1,47 @@
|
|||||||
include_directories(../3rdpart)
|
# MIT License
|
||||||
file(GLOB jsoncpp_src_list ../3rdpart/jsoncpp/*.cpp ../3rdpart/jsoncpp/*.h )
|
#
|
||||||
add_library(jsoncpp STATIC ${jsoncpp_src_list})
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
file(GLOB MediaServer_src_list ./*.cpp ./*.h)
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
file(GLOB MediaServer_SRC_LIST ./*.cpp ./*.h)
|
||||||
|
|
||||||
|
set(COMPILE_DEFINITIONS ${MK_COMPILE_DEFINITIONS})
|
||||||
|
|
||||||
if(ENABLE_SERVER_LIB)
|
if(ENABLE_SERVER_LIB)
|
||||||
add_definitions(-DDISABLE_MAIN)
|
list(APPEND COMPILE_DEFINITIONS DISABLE_MAIN)
|
||||||
add_library(MediaServer STATIC ${MediaServer_src_list})
|
add_library(MediaServer STATIC ${MediaServer_SRC_LIST})
|
||||||
list(APPEND LINK_LIB_LIST MediaServer jsoncpp)
|
target_compile_definitions(MediaServer
|
||||||
set(LINK_LIB_LIST ${LINK_LIB_LIST} PARENT_SCOPE)
|
PRIVATE ${COMPILE_DEFINITIONS})
|
||||||
|
target_compile_options(MediaServer
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
update_cached(MK_LINK_LIBRARIES MediaServer)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(MediaServer ${MediaServer_src_list})
|
add_executable(MediaServer ${MediaServer_SRC_LIST})
|
||||||
|
|
||||||
if(MSVC)
|
install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_RUNTIME})
|
||||||
set_target_properties(MediaServer PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
|
||||||
else()
|
|
||||||
install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_EXECUTABLE})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
target_link_libraries(MediaServer -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group)
|
target_link_libraries(MediaServer -Wl,--start-group ${MK_LINK_LIBRARIES} -Wl,--end-group)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(MediaServer jsoncpp ${LINK_LIB_LIST})
|
target_link_libraries(MediaServer ${MK_LINK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
65
src/CMakeLists.txt
Normal file
65
src/CMakeLists.txt
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
file(GLOB MediaKit_SRC_LIST
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/*/*.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/*/*.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/*/*.h)
|
||||||
|
|
||||||
|
if(USE_SOLUTION_FOLDERS AND (NOT GROUP_BY_EXPLORER))
|
||||||
|
# 在 IDE 中对文件进行分组, 源文件和头文件分开
|
||||||
|
set_file_group("${CMAKE_CURRENT_SOURCE_DIR}" ${MediaKit_SRC_LIST})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# 添加库
|
||||||
|
add_library(zlmediakit STATIC ${MediaKit_SRC_LIST})
|
||||||
|
add_library(ZLMediaKit::MediaKit ALIAS zlmediakit)
|
||||||
|
|
||||||
|
set(LINK_LIBRARIES ${MK_LINK_LIBRARIES})
|
||||||
|
list(REMOVE_ITEM LINK_LIBRARIES ZLMediaKit::MediaKit)
|
||||||
|
set(COMPILE_DEFINITIONS ${MK_COMPILE_DEFINITIONS})
|
||||||
|
|
||||||
|
target_compile_definitions(zlmediakit
|
||||||
|
PRIVATE ${COMPILE_DEFINITIONS})
|
||||||
|
target_compile_options(zlmediakit
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_link_libraries(zlmediakit
|
||||||
|
PRIVATE ${LINK_LIBRARIES})
|
||||||
|
target_include_directories(zlmediakit
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
|
||||||
|
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES ZLMediaKit::MediaKit)
|
||||||
|
|
||||||
|
# 未在使用
|
||||||
|
if(ENABLE_CXX_API)
|
||||||
|
# 保留目录结构
|
||||||
|
install(DIRECTORY ${MediaKit_Root}/
|
||||||
|
DESTINATION ${INSTALL_PATH_INCLUDE}/ZLMediaKit
|
||||||
|
REGEX ".*[.](md|cpp)$" EXCLUDE)
|
||||||
|
install(TARGETS zlmediakit
|
||||||
|
DESTINATION ${INSTALL_PATH_LIB})
|
||||||
|
endif ()
|
44
srt/CMakeLists.txt
Normal file
44
srt/CMakeLists.txt
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
file(GLOB SRT_SRC_LIST *.cpp *.h *.hpp)
|
||||||
|
|
||||||
|
add_library(srt STATIC ${SRT_SRC_LIST})
|
||||||
|
add_library(ZLMediaKit::SRT ALIAS srt)
|
||||||
|
target_link_libraries(srt
|
||||||
|
PUBLIC
|
||||||
|
ZLMediaKit::MediaKit
|
||||||
|
ZLMediaKit::ToolKit)
|
||||||
|
target_compile_options(srt
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_include_directories(srt
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>")
|
||||||
|
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_SRT)
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES ZLMediaKit::SRT)
|
||||||
|
|
||||||
|
message(STATUS "srt 功能已开启")
|
@ -1,4 +1,27 @@
|
|||||||
execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/default.pem ${EXECUTABLE_OUTPUT_PATH}/)
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/default.pem ${EXECUTABLE_OUTPUT_PATH}/)
|
||||||
aux_source_directory(. TEST_SRC_LIST)
|
aux_source_directory(. TEST_SRC_LIST)
|
||||||
|
|
||||||
foreach(TEST_SRC ${TEST_SRC_LIST})
|
foreach(TEST_SRC ${TEST_SRC_LIST})
|
||||||
@ -23,20 +46,8 @@ foreach (TEST_SRC ${TEST_SRC_LIST})
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
target_link_libraries(${TEST_EXE_NAME} -Wl,--start-group ${LINK_LIB_LIST} -Wl,--end-group)
|
target_link_libraries(${TEST_EXE_NAME} -Wl,--start-group ${MK_LINK_LIBRARIES} -Wl,--end-group)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${TEST_EXE_NAME} ${LINK_LIB_LIST})
|
target_link_libraries(${TEST_EXE_NAME} ${MK_LINK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
70
webrtc/CMakeLists.txt
Normal file
70
webrtc/CMakeLists.txt
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# 查找 srtp 是否安装
|
||||||
|
find_package(SRTP QUIET)
|
||||||
|
if(NOT SRTP_FOUND OR NOT ENABLE_OPENSSL)
|
||||||
|
set(ENABLE_WEBRTC OFF)
|
||||||
|
message(WARNING "srtp 未找到, WebRTC 相关功能打开失败")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
message(STATUS "found library: ${SRTP_LIBRARIES}")
|
||||||
|
include_directories(SYSTEM ${SRTP_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
set(LINK_LIBRARIES ${SRTP_LIBRARIES})
|
||||||
|
|
||||||
|
find_package(SCTP QUIET)
|
||||||
|
if(SCTP_FOUND)
|
||||||
|
message(STATUS "found library: ${SCTP_INCLUDE_DIRS} ${SCTP_LIBRARIES}")
|
||||||
|
include_directories(SYSTEM ${SCTP_INCLUDE_DIRS})
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_SCTP)
|
||||||
|
update_cached_list(LINK_LIBRARIES ${SCTP_LIBRARIES})
|
||||||
|
message(STATUS "WebRTC datachannel 功能已打开")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(GLOB WEBRTC_SRC_LIST
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/*.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
||||||
|
add_library(webrtc ${WEBRTC_SRC_LIST})
|
||||||
|
add_library(ZLMediaKit::WebRTC ALIAS webrtc)
|
||||||
|
target_compile_options(webrtc
|
||||||
|
PRIVATE ${COMPILE_OPTIONS_DEFAULT})
|
||||||
|
target_link_libraries(webrtc
|
||||||
|
PRIVATE
|
||||||
|
ZLMediaKit::MediaKit
|
||||||
|
ZLMediaKit::ToolKit
|
||||||
|
PUBLIC
|
||||||
|
${LINK_LIBRARIES})
|
||||||
|
target_include_directories(webrtc
|
||||||
|
PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>")
|
||||||
|
|
||||||
|
message(STATUS "WebRTC 功能已开启")
|
||||||
|
|
||||||
|
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_WEBRTC)
|
||||||
|
update_cached_list(MK_LINK_LIBRARIES ZLMediaKit::WebRTC ${LINK_LIBRARIES})
|
Loading…
Reference in New Issue
Block a user