You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 16KB

6 月之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. # MIT License
  2. #
  3. # Copyright (c) 2016-2022 The ZLMediaKit project authors. All Rights Reserved.
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in all
  13. # copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22. #
  23. cmake_minimum_required(VERSION 3.1.3)
  24. # 加载自定义模块
  25. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  26. project(ZLMediaKit LANGUAGES C CXX)
  27. # 使能 C++11
  28. set(CMAKE_CXX_STANDARD 11)
  29. option(ENABLE_API "Enable C API SDK" ON)
  30. option(ENABLE_API_STATIC_LIB "Enable mk_api static lib" OFF)
  31. option(ENABLE_ASAN "Enable Address Sanitize" OFF)
  32. option(ENABLE_CXX_API "Enable C++ API SDK" OFF)
  33. option(ENABLE_FAAC "Enable FAAC" OFF)
  34. option(ENABLE_FFMPEG "Enable FFmpeg" OFF)
  35. option(ENABLE_HLS "Enable HLS" ON)
  36. option(ENABLE_JEMALLOC_STATIC "Enable static linking to the jemalloc library" OFF)
  37. option(ENABLE_MEM_DEBUG "Enable Memory Debug" OFF)
  38. option(ENABLE_MP4 "Enable MP4" ON)
  39. option(ENABLE_MSVC_MT "Enable MSVC Mt/Mtd lib" ON)
  40. option(ENABLE_MYSQL "Enable MySQL" OFF)
  41. option(ENABLE_OPENSSL "Enable OpenSSL" ON)
  42. option(ENABLE_PLAYER "Enable Player" ON)
  43. option(ENABLE_RTPPROXY "Enable RTPPROXY" ON)
  44. option(ENABLE_SERVER "Enable Server" ON)
  45. option(ENABLE_SERVER_LIB "Enable server as android static library" OFF)
  46. option(ENABLE_SRT "Enable SRT" ON)
  47. option(ENABLE_TESTS "Enable Tests" ON)
  48. option(ENABLE_WEBRTC "Enable WebRTC" ON)
  49. option(ENABLE_X264 "Enable x264" OFF)
  50. option(ENABLE_WEPOLL "Enable wepoll" ON)
  51. option(USE_SOLUTION_FOLDERS "Enable solution dir supported" ON)
  52. ##############################################################################
  53. if("${CMAKE_BUILD_TYPE}" STREQUAL "")
  54. set(CMAKE_BUILD_TYPE "Debug")
  55. endif()
  56. message(STATUS "编译类型: ${CMAKE_BUILD_TYPE}")
  57. # 方便排查编译问题, 需要 FORCE CACHE, 否则需要命令行设置才生效
  58. set(CMAKE_VERBOSE_MAKEFILE ON CACHE INTERNAL "" FORCE)
  59. # TODO: include 当前目录会导致 server 编译出错, 待排除
  60. set(CMAKE_INCLUDE_CURRENT_DIR OFF)
  61. # 安装路径
  62. if(NOT CMAKE_INSTALL_PREFIX)
  63. if(UNIX)
  64. set(INSTALL_PATH_LIB lib${LIB_SUFFIX})
  65. set(INSTALL_PATH_INCLUDE include)
  66. set(INSTALL_PATH_RUNTIME bin)
  67. elseif(WIN32)
  68. # Windows 下安装到了用户主目录下?
  69. set(INSTALL_PATH_LIB $ENV{HOME}/${CMAKE_PROJECT_NAME}/lib)
  70. set(INSTALL_PATH_INCLUDE $ENV{HOME}/${CMAKE_PROJECT_NAME}/include)
  71. else()
  72. message(WARNING "该平台(${CMAKE_SYSTEM_NAME})下暂未设置安装路径")
  73. endif()
  74. else()
  75. set(INSTALL_PATH_LIB ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
  76. set(INSTALL_PATH_INCLUDE ${CMAKE_INSTALL_PREFIX}/include)
  77. set(INSTALL_PATH_RUNTIME ${CMAKE_INSTALL_PREFIX}/bin)
  78. endif()
  79. string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_LOWER)
  80. # 设置输出目录, 包括 bin, lib 以及其他文件
  81. # Windows 也不再区分 32/64
  82. set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/release/${SYSTEM_NAME_LOWER}/${CMAKE_BUILD_TYPE})
  83. set(LIBRARY_OUTPUT_PATH ${OUTPUT_DIR})
  84. set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_DIR})
  85. # 添加 git 版本信息
  86. set(COMMIT_HASH "Git_Unkown_commit")
  87. set(COMMIT_TIME "Git_Unkown_time")
  88. set(BRANCH_NAME "Git_Unkown_branch")
  89. set(BUILD_TIME "")
  90. string(TIMESTAMP BUILD_TIME "%Y-%m-%dT%H:%M:%S")
  91. find_package(Git QUIET)
  92. if(GIT_FOUND)
  93. execute_process(
  94. COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD
  95. OUTPUT_VARIABLE COMMIT_HASH
  96. OUTPUT_STRIP_TRAILING_WHITESPACE
  97. ERROR_QUIET
  98. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  99. execute_process(
  100. COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
  101. OUTPUT_VARIABLE BRANCH_NAME
  102. OUTPUT_STRIP_TRAILING_WHITESPACE
  103. ERROR_QUIET
  104. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  105. execute_process(
  106. COMMAND ${GIT_EXECUTABLE} log --format=format:%aI -1
  107. OUTPUT_VARIABLE COMMIT_TIME
  108. OUTPUT_STRIP_TRAILING_WHITESPACE
  109. ERROR_QUIET
  110. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  111. endif()
  112. configure_file(
  113. ${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini
  114. ${CMAKE_CURRENT_BINARY_DIR}/version.h
  115. @ONLY)
  116. message(STATUS "Git version is ${BRANCH_NAME} ${COMMIT_HASH}/${COMMIT_TIME} ${BUILD_TIME}")
  117. ##############################################################################
  118. # 方便修改全局变量
  119. function(update_cached name value)
  120. set("${name}" "${value}" CACHE INTERNAL "*** Internal ***" FORCE)
  121. endfunction()
  122. function(update_cached_list name)
  123. set(_tmp_list "${${name}}")
  124. list(APPEND _tmp_list "${ARGN}")
  125. list(REMOVE_DUPLICATES _tmp_list)
  126. update_cached(${name} "${_tmp_list}")
  127. endfunction()
  128. # TODO:
  129. function(set_file_group prefix)
  130. message(STATUS "set_file_group " ${prefix} " " ${ARGC})
  131. foreach(FILE IN LISTS ARGN 1)
  132. # Get the directory of the source file
  133. get_filename_component(PARENT_DIR "${FILE}" DIRECTORY)
  134. # Remove common directory prefix to make the group
  135. string(REPLACE "${prefix}" "" GROUP "${PARENT_DIR}")
  136. # Make sure we are using windows slashes
  137. string(REPLACE "/" "\\" GROUP "${GROUP}")
  138. source_group("${GROUP}" FILES "${FILE}")
  139. endforeach()
  140. endfunction()
  141. find_program(CCACHE_FOUND ccache)
  142. if(CCACHE_FOUND)
  143. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  144. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  145. endif()
  146. if(UNIX)
  147. # UNIX/Linux/Darwin
  148. set(COMPILE_OPTIONS_DEFAULT
  149. "-fPIC"
  150. "-Wall;-Wextra"
  151. "-Wno-unused-function;-Wno-unused-parameter;-Wno-unused-variable"
  152. "-Wno-error=extra;-Wno-error=missing-field-initializers;-Wno-error=type-limits")
  153. elseif(WIN32)
  154. if (MSVC)
  155. set(COMPILE_OPTIONS_DEFAULT
  156. # TODO: /wd4819 应该是不会生效
  157. "/wd4566;/wd4819"
  158. # warning C4530: C++ exception handler used, but unwind semantics are not enabled.
  159. "/EHsc")
  160. # disable Windows logo
  161. list(APPEND COMPILE_OPTIONS_DEFAULT "/nologo")
  162. list(APPEND CMAKE_STATIC_LINKER_FLAGS "/nologo")
  163. endif()
  164. endif()
  165. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  166. if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
  167. include_directories(SYSTEM "/opt/homebrew/include")
  168. endif()
  169. endif()
  170. # mediakit 以及各个 runtime 依赖
  171. update_cached_list(MK_LINK_LIBRARIES "")
  172. update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_VERSION)
  173. if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  174. include(CheckCXXSourceCompiles)
  175. file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/checks/atomic_check.cpp atomic_check_cpp)
  176. check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITHOUT_LIB)
  177. if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
  178. # cmake --help-policy CMP0075
  179. list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
  180. check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITH_LIB)
  181. if(NOT HAVE_CXX_ATOMICS_WITH_LIB)
  182. message(WARNING "Compiler doesn't support std::atomic<long long>")
  183. else()
  184. update_cached_list(MK_LINK_LIBRARIES atomic)
  185. endif()
  186. endif()
  187. endif()
  188. # 多个模块依赖 ffmpeg 相关库, 统一查找
  189. if(ENABLE_FFMPEG)
  190. find_package(PkgConfig QUIET)
  191. # 查找 ffmpeg/libutil 是否安装
  192. if(PKG_CONFIG_FOUND)
  193. pkg_check_modules(AVUTIL QUIET IMPORTED_TARGET libavutil)
  194. if(AVUTIL_FOUND)
  195. update_cached_list(MK_LINK_LIBRARIES PkgConfig::AVUTIL)
  196. message(STATUS "found library: ${AVUTIL_LIBRARIES}")
  197. endif()
  198. endif()
  199. # 查找 ffmpeg/libavcodec 是否安装
  200. if(PKG_CONFIG_FOUND)
  201. pkg_check_modules(AVCODEC QUIET IMPORTED_TARGET libavcodec)
  202. if(AVCODEC_FOUND)
  203. update_cached_list(MK_LINK_LIBRARIES PkgConfig::AVCODEC)
  204. message(STATUS "found library: ${AVCODEC_LIBRARIES}")
  205. endif()
  206. endif()
  207. # 查找 ffmpeg/libswscale 是否安装
  208. if(PKG_CONFIG_FOUND)
  209. pkg_check_modules(SWSCALE QUIET IMPORTED_TARGET libswscale)
  210. if(SWSCALE_FOUND)
  211. update_cached_list(MK_LINK_LIBRARIES PkgConfig::SWSCALE)
  212. message(STATUS "found library: ${SWSCALE_LIBRARIES}")
  213. endif()
  214. endif()
  215. # 查找 ffmpeg/libswresample 是否安装
  216. if(PKG_CONFIG_FOUND)
  217. pkg_check_modules(SWRESAMPLE QUIET IMPORTED_TARGET libswresample)
  218. if(SWRESAMPLE_FOUND)
  219. update_cached_list(MK_LINK_LIBRARIES PkgConfig::SWRESAMPLE)
  220. message(STATUS "found library: ${SWRESAMPLE_LIBRARIES}")
  221. endif()
  222. endif()
  223. # 查找 ffmpeg/libutil 是否安装
  224. if(NOT AVUTIL_FOUND)
  225. find_package(AVUTIL QUIET)
  226. if(AVUTIL_FOUND)
  227. include_directories(SYSTEM ${AVUTIL_INCLUDE_DIR})
  228. update_cached_list(MK_LINK_LIBRARIES ${AVUTIL_LIBRARIES})
  229. message(STATUS "found library: ${AVUTIL_LIBRARIES}")
  230. endif ()
  231. endif ()
  232. # 查找 ffmpeg/libavcodec 是否安装
  233. if(NOT AVCODEC_FOUND)
  234. find_package(AVCODEC QUIET)
  235. if(AVCODEC_FOUND)
  236. include_directories(SYSTEM ${AVCODEC_INCLUDE_DIR})
  237. update_cached_list(MK_LINK_LIBRARIES ${AVCODEC_LIBRARIES})
  238. message(STATUS "found library: ${AVCODEC_LIBRARIES}")
  239. endif()
  240. endif()
  241. # 查找 ffmpeg/libswscale 是否安装
  242. if(NOT SWSCALE_FOUND)
  243. find_package(SWSCALE QUIET)
  244. if(SWSCALE_FOUND)
  245. include_directories(SYSTEM ${SWSCALE_INCLUDE_DIR})
  246. update_cached_list(MK_LINK_LIBRARIES ${SWSCALE_LIBRARIES})
  247. message(STATUS "found library: ${SWSCALE_LIBRARIES}")
  248. endif()
  249. endif()
  250. # 查找 ffmpeg/libswresample 是否安装
  251. if(NOT SWRESAMPLE_FOUND)
  252. find_package(SWRESAMPLE QUIET)
  253. if(SWRESAMPLE_FOUND)
  254. include_directories(SYSTEM ${SWRESAMPLE_INCLUDE_DIRS})
  255. update_cached_list(MK_LINK_LIBRARIES ${SWRESAMPLE_LIBRARIES})
  256. message(STATUS "found library: ${SWRESAMPLE_LIBRARIES}")
  257. endif()
  258. endif()
  259. if(AVUTIL_FOUND AND AVCODEC_FOUND AND SWSCALE_FOUND AND SWRESAMPLE_FOUND)
  260. update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_FFMPEG)
  261. update_cached_list(MK_LINK_LIBRARIES ${CMAKE_DL_LIBS})
  262. else()
  263. set(ENABLE_FFMPEG OFF)
  264. message(WARNING "ffmpeg 相关功能未找到")
  265. endif()
  266. endif()
  267. if(ENABLE_MEM_DEBUG)
  268. update_cached_list(MK_LINK_LIBRARIES
  269. "-Wl,-wrap,free;-Wl,-wrap,malloc;-Wl,-wrap,realloc;-Wl,-wrap,calloc")
  270. update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_MEM_DEBUG)
  271. message(STATUS "已启用内存调试功能")
  272. endif()
  273. if(ENABLE_ASAN)
  274. list(APPEND COMPILE_OPTIONS_DEFAULT
  275. "-fsanitize=address;-fno-omit-frame-pointer")
  276. # https://github.com/google/sanitizers/wiki/AddressSanitizer#using-addresssanitizer
  277. # > In order to use AddressSanitizer you will need to
  278. # > compile and link your program using clang with the -fsanitize=address switch.
  279. update_cached_list(MK_LINK_LIBRARIES "-fsanitize=address")
  280. message(STATUS "已启用 Address Sanitize")
  281. endif()
  282. # TODO: 下载静态编译 jemalloc 后静态编译链接?
  283. set(DEP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdpart/external-${CMAKE_SYSTEM_NAME})
  284. if(ENABLE_JEMALLOC_STATIC)
  285. if(NOT EXISTS ${DEP_ROOT_DIR})
  286. file(MAKE_DIRECTORY ${DEP_ROOT_DIR})
  287. endif()
  288. include(Jemalloc)
  289. include_directories(SYSTEM ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/include/jemalloc)
  290. link_directories(${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib)
  291. # 用于影响后续查找过程
  292. set(JEMALLOC_ROOT_DIR "${DEP_ROOT_DIR}/${JEMALLOC_NAME}")
  293. endif()
  294. # 默认链接 jemalloc 库避免内存碎片
  295. find_package(JEMALLOC QUIET)
  296. if(JEMALLOC_FOUND)
  297. message(STATUS "found library: ${JEMALLOC_LIBRARIES}")
  298. include_directories(${JEMALLOC_INCLUDE_DIR})
  299. update_cached_list(MK_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
  300. endif()
  301. # 查找 openssl 是否安装
  302. find_package(OpenSSL QUIET)
  303. if(OPENSSL_FOUND AND ENABLE_OPENSSL)
  304. message(STATUS "found library: ${OPENSSL_LIBRARIES}, ENABLE_OPENSSL defined")
  305. include_directories(${OPENSSL_INCLUDE_DIR})
  306. update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_OPENSSL)
  307. update_cached_list(MK_LINK_LIBRARIES ${OPENSSL_LIBRARIES})
  308. if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND OPENSSL_USE_STATIC_LIBS)
  309. update_cached_list(MK_LINK_LIBRARIES ${CMAKE_DL_LIBS})
  310. endif()
  311. else()
  312. set(ENABLE_OPENSSL OFF)
  313. set(ENABLE_WEBRTC OFF)
  314. message(WARNING "openssl 未找到, rtmp 将不支持 flash 播放器, https/wss/rtsps/rtmps/webrtc 也将失效")
  315. endif()
  316. # 查找 mysql 是否安装
  317. find_package(MYSQL QUIET)
  318. if(MYSQL_FOUND AND ENABLE_MYSQL)
  319. message(STATUS "found library: ${MYSQL_LIBRARIES}, ENABLE_MYSQL defined")
  320. include_directories(SYSTEM
  321. ${MYSQL_INCLUDE_DIR}
  322. ${MYSQL_INCLUDE_DIR}/mysql)
  323. update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_MYSQL)
  324. update_cached_list(MK_LINK_LIBRARIES ${MYSQL_LIBRARIES})
  325. endif()
  326. # 查找 x264 是否安装
  327. find_package(X264 QUIET)
  328. if(X264_FOUND AND ENABLE_X264)
  329. message(STATUS "found library: ${X264_LIBRARIES}, ENABLE_X264 defined")
  330. include_directories(SYSTEM ${X264_INCLUDE_DIRS})
  331. update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_X264)
  332. update_cached_list(MK_LINK_LIBRARIES ${X264_LIBRARIES})
  333. endif()
  334. # 查找 faac 是否安装
  335. find_package(FAAC QUIET)
  336. if(FAAC_FOUND AND ENABLE_FAAC)
  337. message(STATUS "found library:${FAAC_LIBRARIES}, ENABLE_FAAC defined")
  338. include_directories(SYSTEM ${FAAC_INCLUDE_DIR})
  339. update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_FAAC)
  340. update_cached_list(MK_LINK_LIBRARIES ${FAAC_LIBRARIES})
  341. endif()
  342. if(WIN32)
  343. update_cached_list(MK_LINK_LIBRARIES WS2_32 Iphlpapi shlwapi)
  344. elseif(NOT ANDROID OR IOS)
  345. update_cached_list(MK_LINK_LIBRARIES pthread)
  346. endif()
  347. # ----------------------------------------------------------------------------
  348. # Solution folders:
  349. # ----------------------------------------------------------------------------
  350. if(USE_SOLUTION_FOLDERS)
  351. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  352. set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
  353. endif()
  354. if(MSVC AND ENABLE_MSVC_MT)
  355. set(CompilerFlags
  356. CMAKE_CXX_FLAGS
  357. CMAKE_CXX_FLAGS_DEBUG
  358. CMAKE_CXX_FLAGS_RELEASE
  359. CMAKE_C_FLAGS
  360. CMAKE_C_FLAGS_DEBUG
  361. CMAKE_C_FLAGS_RELEASE)
  362. # TODO: 通常应该不需要替换
  363. foreach(CompilerFlag ${CompilerFlags})
  364. string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
  365. endforeach()
  366. endif()
  367. ##############################################################################
  368. # for version.h
  369. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  370. # for assert.h
  371. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdpart)
  372. add_subdirectory(3rdpart)
  373. add_subdirectory(src)
  374. if(ENABLE_SRT)
  375. add_subdirectory(srt)
  376. endif()
  377. if(ENABLE_WEBRTC)
  378. add_subdirectory(webrtc)
  379. endif()
  380. if(ENABLE_API)
  381. add_subdirectory(api)
  382. endif()
  383. # IOS 不编译可执行程序
  384. if(IOS)
  385. return()
  386. endif()
  387. ##############################################################################
  388. if(ENABLE_PLAYER AND ENABLE_FFMPEG)
  389. add_subdirectory(player)
  390. endif()
  391. #MediaServer主程序
  392. add_subdirectory(server)
  393. # Android 会 add_subdirectory 并依赖该变量
  394. if(ENABLE_SERVER_LIB)
  395. set(MK_LINK_LIBRARIES ${MK_LINK_LIBRARIES} PARENT_SCOPE)
  396. endif()
  397. #cpp测试demo程序
  398. if (ENABLE_TESTS)
  399. add_subdirectory(tests)
  400. endif ()
  401. # 拷贝www文件夹、配置文件、默认证书
  402. file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/www" DESTINATION ${EXECUTABLE_OUTPUT_PATH})
  403. file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf/config.ini" DESTINATION ${EXECUTABLE_OUTPUT_PATH})
  404. file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/default.pem" DESTINATION ${EXECUTABLE_OUTPUT_PATH})