2017-10-09 22:11:01 +08:00
|
|
|
|
project(ZLMediaKit)
|
2018-03-21 16:01:41 +08:00
|
|
|
|
cmake_minimum_required(VERSION 3.1.3)
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#使能c++11
|
2018-03-21 16:01:41 +08:00
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
|
|
|
|
#加载自定义模块
|
2017-05-02 23:43:10 +08:00
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
2017-05-02 18:10:47 +08:00
|
|
|
|
#设置库文件路径
|
|
|
|
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
|
|
|
|
#设置可执行程序路径
|
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
2017-07-27 17:06:37 +08:00
|
|
|
|
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#设置工程源码根目录
|
2019-04-01 12:57:33 +08:00
|
|
|
|
set(ToolKit_Root ${CMAKE_SOURCE_DIR}/3rdpart/ZLToolKit/src)
|
2018-03-21 15:13:33 +08:00
|
|
|
|
set(MediaKit_Root ${CMAKE_SOURCE_DIR}/src)
|
2017-08-09 18:39:30 +08:00
|
|
|
|
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#设置头文件目录
|
|
|
|
|
INCLUDE_DIRECTORIES(${ToolKit_Root})
|
|
|
|
|
INCLUDE_DIRECTORIES(${MediaKit_Root})
|
2017-08-09 18:39:30 +08:00
|
|
|
|
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#收集源代码
|
|
|
|
|
file(GLOB ToolKit_src_list ${ToolKit_Root}/*/*.cpp ${ToolKit_Root}/*/*.h ${ToolKit_Root}/*/*.c)
|
|
|
|
|
file(GLOB MediaKit_src_list ${MediaKit_Root}/*/*.cpp ${MediaKit_Root}/*/*.h ${MediaKit_Root}/*/*.c)
|
2017-08-09 18:39:30 +08:00
|
|
|
|
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#去除win32的适配代码
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
|
list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c)
|
2018-05-07 10:02:37 +08:00
|
|
|
|
else()
|
|
|
|
|
#防止Windows.h包含Winsock.h
|
2018-05-22 11:41:20 +08:00
|
|
|
|
add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS)
|
2018-03-21 15:13:33 +08:00
|
|
|
|
endif ()
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
2019-04-04 11:30:57 +08:00
|
|
|
|
set(ENABLE_HLS true)
|
|
|
|
|
set(ENABLE_OPENSSL true)
|
|
|
|
|
set(ENABLE_MYSQL true)
|
|
|
|
|
set(ENABLE_MP4V2 true)
|
|
|
|
|
set(ENABLE_FAAC true)
|
|
|
|
|
set(ENABLE_X264 true)
|
|
|
|
|
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#添加两个静态库
|
2019-04-04 11:30:57 +08:00
|
|
|
|
if(ENABLE_HLS)
|
|
|
|
|
message(STATUS "ENABLE_HLS defined")
|
2019-04-04 11:41:51 +08:00
|
|
|
|
add_definitions(-DENABLE_HLS)
|
|
|
|
|
set(MediaServer_Root ${CMAKE_SOURCE_DIR}/3rdpart/media-server)
|
|
|
|
|
set(LINK_LIB_LIST zlmediakit zltoolkit mpeg)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
else()
|
|
|
|
|
set(LINK_LIB_LIST zlmediakit zltoolkit)
|
|
|
|
|
endif()
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
|
|
|
|
#查找openssl是否安装
|
2017-05-11 22:10:12 +08:00
|
|
|
|
find_package(OpenSSL QUIET)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
if (OPENSSL_FOUND AND ENABLE_OPENSSL)
|
|
|
|
|
message(STATUS "found library:${OPENSSL_LIBRARIES},ENABLE_OPENSSL defined")
|
2017-12-01 11:42:49 +08:00
|
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
|
|
|
add_definitions(-DENABLE_OPENSSL)
|
|
|
|
|
list(APPEND LINK_LIB_LIST ${OPENSSL_LIBRARIES})
|
2019-04-04 11:30:57 +08:00
|
|
|
|
endif ()
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
|
|
|
|
#查找mysql是否安装
|
|
|
|
|
find_package(MYSQL QUIET)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
if (MYSQL_FOUND AND ENABLE_MYSQL)
|
|
|
|
|
message(STATUS "found library:${MYSQL_LIBRARIES},ENABLE_MYSQL defined")
|
2017-12-01 11:42:49 +08:00
|
|
|
|
include_directories(${MYSQL_INCLUDE_DIR})
|
2019-05-24 17:50:46 +08:00
|
|
|
|
include_directories(${MYSQL_INCLUDE_DIR}/mysql)
|
2017-12-01 11:42:49 +08:00
|
|
|
|
add_definitions(-DENABLE_MYSQL)
|
|
|
|
|
list(APPEND LINK_LIB_LIST ${MYSQL_LIBRARIES})
|
2019-04-04 11:30:57 +08:00
|
|
|
|
endif ()
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#查找MP4V2是否安装
|
2017-05-02 18:10:47 +08:00
|
|
|
|
find_package(MP4V2 QUIET)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
if (MP4V2_FOUND AND ENABLE_MP4V2)
|
2017-12-01 11:42:49 +08:00
|
|
|
|
include_directories(${MP4V2_INCLUDE_DIR})
|
2018-03-21 15:13:33 +08:00
|
|
|
|
list(APPEND LINK_LIB_LIST ${MP4V2_LIBRARY})
|
2017-12-01 11:42:49 +08:00
|
|
|
|
add_definitions(-DENABLE_MP4V2)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
message(STATUS "found library:${MP4V2_LIBRARY},ENABLE_MP4V2 defined")
|
|
|
|
|
endif ()
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
|
|
|
|
#查找x264是否安装
|
|
|
|
|
find_package(X264 QUIET)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
if (X264_FOUND AND ENABLE_X264)
|
|
|
|
|
message(STATUS "found library:${X264_LIBRARIES},ENABLE_X264 defined")
|
2017-12-01 11:42:49 +08:00
|
|
|
|
include_directories(${X264_INCLUDE_DIRS})
|
|
|
|
|
add_definitions(-DENABLE_X264)
|
|
|
|
|
list(APPEND LINK_LIB_LIST ${X264_LIBRARIES})
|
2018-03-21 15:13:33 +08:00
|
|
|
|
endif ()
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
|
|
|
|
#查找faac是否安装
|
|
|
|
|
find_package(FAAC QUIET)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
if (FAAC_FOUND AND ENABLE_FAAC)
|
|
|
|
|
message(STATUS "found library:${FAAC_LIBRARIES},ENABLE_FAAC defined")
|
2017-12-01 11:42:49 +08:00
|
|
|
|
include_directories(${FAAC_INCLUDE_DIR})
|
|
|
|
|
add_definitions(-DENABLE_FAAC)
|
|
|
|
|
list(APPEND LINK_LIB_LIST ${FAAC_LIBRARIES})
|
2018-03-21 15:13:33 +08:00
|
|
|
|
endif ()
|
2017-05-03 00:05:30 +08:00
|
|
|
|
|
2019-05-31 12:14:51 +08:00
|
|
|
|
|
2018-03-21 15:13:33 +08:00
|
|
|
|
#添加库
|
|
|
|
|
add_library(zltoolkit STATIC ${ToolKit_src_list})
|
|
|
|
|
add_library(zlmediakit STATIC ${MediaKit_src_list})
|
|
|
|
|
|
2019-05-31 12:14:51 +08:00
|
|
|
|
|
|
|
|
|
set(VS_FALGS "/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573 /utf-8" )
|
2019-04-01 12:57:33 +08:00
|
|
|
|
#libmpeg
|
2019-04-04 11:30:57 +08:00
|
|
|
|
if(ENABLE_HLS)
|
|
|
|
|
aux_source_directory(${MediaServer_Root}/libmpeg/include src_mpeg)
|
|
|
|
|
aux_source_directory(${MediaServer_Root}/libmpeg/source src_mpeg)
|
|
|
|
|
include_directories(${MediaServer_Root}/libmpeg/include)
|
|
|
|
|
add_library(mpeg STATIC ${src_mpeg})
|
2019-05-31 12:14:51 +08:00
|
|
|
|
if(WIN32)
|
|
|
|
|
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
|
|
|
|
endif(WIN32)
|
2019-04-04 11:30:57 +08:00
|
|
|
|
endif()
|
2019-04-01 12:57:33 +08:00
|
|
|
|
|
2018-03-21 16:16:04 +08:00
|
|
|
|
if (WIN32)
|
2018-03-21 15:13:33 +08:00
|
|
|
|
list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
|
2019-05-31 12:14:51 +08:00
|
|
|
|
set_target_properties(zltoolkit PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
|
|
|
|
set_target_properties(zlmediakit PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
2018-03-27 00:40:22 +08:00
|
|
|
|
elseif(NOT ANDROID OR IOS)
|
2018-03-21 16:16:04 +08:00
|
|
|
|
list(APPEND LINK_LIB_LIST pthread)
|
2018-03-21 15:13:33 +08:00
|
|
|
|
endif ()
|
|
|
|
|
|
2019-05-31 12:14:51 +08:00
|
|
|
|
|
|
|
|
|
|
2017-05-02 18:10:47 +08:00
|
|
|
|
#测试程序
|
2018-03-21 15:13:33 +08:00
|
|
|
|
add_subdirectory(tests)
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
2019-05-20 11:22:59 +08:00
|
|
|
|
#主服务器
|
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
|
add_subdirectory(server)
|
|
|
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
|
|
|
add_subdirectory(server)
|
|
|
|
|
endif ()
|
2017-05-02 18:10:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|