AW-Security-Media-Lib/CMakeLists.txt

161 lines
6.0 KiB
CMake
Raw Normal View History

2022-09-18 03:35:35 +08:00
cmake_minimum_required(VERSION 3.9)
2024-08-05 10:53:47 +08:00
project(
SecMedia
2024-08-22 14:55:41 +08:00
LANGUAGES C CXX
2024-08-05 10:53:47 +08:00
VERSION 0.0.1
DESCRIPTION "Security Media Package")
2022-09-18 03:57:32 +08:00
set(CMAKE_CXX_STANDARD 11)
2022-09-18 03:35:35 +08:00
2022-09-18 05:14:38 +08:00
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
2024-08-05 10:53:47 +08:00
message(STATUS "Release版本")
set(BuildType "Release")
add_definitions(-DNDEBUG)
2022-09-18 05:14:38 +08:00
elseif(${CMAKE_BUILD_TYPE} MATCHES "MinSizeRel")
2024-08-05 10:53:47 +08:00
message(STATUS "MinSizeRel版本")
set(BuildType "MinSizeRel")
2022-09-18 05:14:38 +08:00
else()
2024-08-05 10:53:47 +08:00
set(BuildType "Debug")
message(STATUS "Debug版本")
add_definitions(-DDEBUG_LOG)
add_definitions(-DNDEBUG)
add_definitions(-DDUMP_FILE)
2022-09-18 05:14:38 +08:00
endif()
2024-08-05 10:53:47 +08:00
# 加载自定义模块
2023-10-26 21:54:29 -06:00
add_definitions(-DSIGN_ENABLE)
2023-06-30 09:38:13 -06:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2022-09-18 05:14:38 +08:00
2024-08-05 10:53:47 +08:00
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/release/lib/${BuildType})
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/release/out)
2022-09-18 03:35:35 +08:00
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
2023-10-26 21:54:29 -06:00
# set(CMAKE_C_FLAGS$ "${CMAKE_C_FLAGS} -fvisibility = hidden")
# set(CMAKE_CXX_FLAGS$ "${CMAKE_CXX_FLAGS} -fvisibility = hidden")
2024-08-28 14:54:06 +08:00
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address
# -fno-omit-frame-pointer")
2023-03-14 04:30:54 -06:00
set(SecMedia_Root ${CMAKE_CURRENT_SOURCE_DIR}/src)
2022-09-18 03:35:35 +08:00
add_compile_options(-fPIC)
2024-08-05 10:53:47 +08:00
# add_compile_options(-fvisibility=hidden) add_compile_options(-std=c++11)
# add_compile_options(-mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4
# -mno-unaligned-access -fno-aggressive-loop-optimizations -Wcast-align)
2022-09-18 03:35:35 +08:00
include(GNUInstallDirs)
include(GenerateExportHeader)
2023-03-14 04:30:54 -06:00
2024-08-05 10:53:47 +08:00
# media-server ps dec enc
2023-10-26 21:54:29 -06:00
set(MediaServer_Root ${SecMedia_Root}/3rdpart/media-server)
2024-08-24 17:51:41 +08:00
add_library(rtp STATIC "")
2023-10-26 21:54:29 -06:00
aux_source_directory(${MediaServer_Root}/libmpeg/include src_rtp)
aux_source_directory(${MediaServer_Root}/libmpeg/source src_rtp)
aux_source_directory(${MediaServer_Root}/librtp/include src_rtp)
aux_source_directory(${MediaServer_Root}/librtp/source src_rtp)
aux_source_directory(${MediaServer_Root}/librtp/payload src_rtp)
2024-08-24 17:51:41 +08:00
target_sources(rtp PRIVATE ${src_rtp})
foreach(src ${src_rtp})
message(STATUS "rtp src: ${src}")
endforeach()
2024-08-28 09:57:33 +08:00
target_include_directories(
rtp
PUBLIC ${MediaServer_Root}/librtp/include ${MediaServer_Root}/libmpeg/include
${MediaServer_Root}/libmpeg/source)
2023-10-26 21:54:29 -06:00
2023-03-14 04:30:54 -06:00
include_directories(${SecMedia_Root}/SVAC/src/svac_src)
2024-08-05 10:53:47 +08:00
# 添加svac解密
2023-03-14 04:30:54 -06:00
aux_source_directory(${SecMedia_Root}/SVAC/src/sm2sm3 src_DEC)
aux_source_directory(${SecMedia_Root}/SVAC/src/svac_src src_DEC)
add_library(SVAC_DEC STATIC ${src_DEC})
2024-08-24 17:51:41 +08:00
# 添加svac加密 include_directories(${DEC_ENC_Algoruithm}/SVAC/svac_enc) file(GLOB
2024-08-05 10:53:47 +08:00
# src_DEC_ENC ${DEC_ENC_Algorithm}/SVAC/svac_enc/*/*.c
# ${DEC_ENC_Algorithm}/SVAC/svac_enc/*/*.h)
2023-03-14 04:30:54 -06:00
aux_source_directory(${SecMedia_Root}/SVAC/src/sm2sm3_enc src_ENC)
aux_source_directory(${SecMedia_Root}/SVAC/src/svac_src src_ENC)
add_library(SVAC_ENC STATIC ${src_ENC})
list(APPEND LINK_LIB_SVAC_LIST SVAC_DEC)
list(APPEND LINK_LIB_SVAC_LIST SVAC_ENC)
2024-08-05 10:53:47 +08:00
# 添加密码卡库 add_definitions(-DENABLE_HARDWARE_SIGN) list(APPEND LINK_LIB_SVAC_LIST
# sm.so)
2022-09-18 03:35:35 +08:00
include_directories(include src)
2022-09-18 04:18:06 +08:00
# add_definitions(-DGENERATE_EXPORT)
2022-09-18 03:35:35 +08:00
2024-08-05 10:53:47 +08:00
# file(GLOB SecMedia_src_list ${SecMedia_Root}/SVAC/./*.c
# ${SecMedia_Root}/SVAC/./*.h)
2024-08-24 17:51:41 +08:00
macro(append_srcs out_var root_dir)
file(GLOB_RECURSE srcs ${root_dir}/*.c ${root_dir}/*.cpp)
list(APPEND ${out_var} ${srcs})
endmacro(append_srcs)
append_srcs(SecMedia_src_list ${SecMedia_Root}/DecEnc)
append_srcs(SecMedia_src_list ${SecMedia_Root}/Decrypt)
append_srcs(SecMedia_src_list ${SecMedia_Root}/Encrypt)
append_srcs(SecMedia_src_list ${SecMedia_Root}/GB28181)
append_srcs(SecMedia_src_list ${SecMedia_Root}/HuaWei)
# append_srcs(SecMedia_src_list ${SecMedia_Root}/SVAC)
append_srcs(SecMedia_src_list ${SecMedia_Root}/base)
# message(STATUS "SRCS: ${SecMedia_src_list}")
2024-08-28 09:57:33 +08:00
# file( GLOB SecMedia_src_list ${SecMedia_Root}/*/*.cpp ${SecMedia_Root}/*/*.h
# ${SecMedia_Root}/*/*.c ${SecMedia_Root}/*/*/*.cpp ${SecMedia_Root}/*/*/*.h
# ${SecMedia_Root}/*/*/*.c )
2024-08-05 10:53:47 +08:00
file(GLOB SecMedia_api_list ${CMAKE_CURRENT_SOURCE_DIR}/include/common.h)
2022-09-18 03:35:35 +08:00
2023-03-14 04:30:54 -06:00
# # target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden)
2023-05-30 10:28:40 -06:00
# list(APPEND LINK_LIB_LIST ${LINK_LIB_SVAC_LIST})
2024-08-28 14:54:06 +08:00
#
find_package(Threads REQUIRED)
2022-09-18 03:35:35 +08:00
2024-08-24 17:51:41 +08:00
add_library(${PROJECT_NAME} SHARED ${SecMedia_src_list})
2023-05-30 10:28:40 -06:00
# add_library(${PROJECT_NAME} STATIC ${SecMedia_src_list})
2024-08-28 14:54:06 +08:00
target_link_libraries(${PROJECT_NAME} PUBLIC ${LINK_LIB_SVAC_LIST} rtp
Threads::Threads)
2024-08-28 09:57:33 +08:00
target_include_directories(
${PROJECT_NAME}
PRIVATE ${SecMedia_Root}
${SecMedia_Root}/3rdpart/media-server/libdash/include
${SecMedia_Root}/3rdpart/media-server/libflv/include
${SecMedia_Root}/3rdpart/media-server/libhls/include
${SecMedia_Root}/3rdpart/media-server/libmov/include
${SecMedia_Root}/3rdpart/media-server/libmpeg/include
${SecMedia_Root}/3rdpart/media-server/librtmp/include
${SecMedia_Root}/3rdpart/media-server/librtp/include
${SecMedia_Root}/3rdpart/media-server/librtsp/include
${SecMedia_Root}/3rdpart/media-server/libsip/include)
2022-09-18 03:35:35 +08:00
2024-08-05 10:53:47 +08:00
# set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION}
2024-08-28 09:57:33 +08:00
# SOVERSION 1 PUBLIC_HEADER ${SecMedia_api_list} ) CXX_VISIBILITY_PRESET hidden
# CMAKE_C_FLAGS hidden)
2022-09-18 03:35:35 +08:00
2024-08-05 10:53:47 +08:00
list(APPEND LINK_LIB_LIST ${PROJECT_NAME})
2023-05-30 10:28:40 -06:00
list(APPEND LINK_LIB_LIST pthread)
2023-06-30 09:38:13 -06:00
2024-08-05 10:53:47 +08:00
# 查找jemalloc是否安装
2023-06-30 09:38:13 -06:00
find_package(JEMALLOC QUIET)
if(JEMALLOC_FOUND)
2024-08-05 10:53:47 +08:00
message(STATUS "found library:\"${JEMALLOC_LIBRARIES}\"")
include_directories(${JEMALLOC_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${JEMALLOC_LIBRARIES})
2023-06-30 09:38:13 -06:00
else()
2024-08-05 10:53:47 +08:00
message(WARNING "JEMALLOC not found")
2023-06-30 09:38:13 -06:00
endif()
2024-08-05 10:53:47 +08:00
# set(LINK_LIB_LIST ) MESSAGE(STATUS ${SecMedia_api_list})
# configure_file(SecMedia.pc.in SecMedia.pc @ONLY)
2023-06-30 09:38:13 -06:00
2024-08-05 10:53:47 +08:00
# install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES
# ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION
# ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
2022-09-18 04:59:50 +08:00
2024-08-28 09:57:33 +08:00
if(BUILD_TOOLS)
add_subdirectory(test)
add_subdirectory(PcapSender)
add_subdirectory(PcapRawSender)
add_subdirectory(SecSetGen)
endif(BUILD_TOOLS)