safesight-edge/plugins/CMakeLists.txt
2025-12-09 15:03:13 +08:00

65 lines
2.5 KiB
CMake

set(RK_PLUGIN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/plugins)
option(RK3588_ENABLE_FFMPEG "Enable FFmpeg-based RTSP input" OFF)
option(RK3588_ENABLE_MPP "Enable Rockchip MPP decode/encode" OFF)
if(RK3588_ENABLE_FFMPEG)
find_package(PkgConfig REQUIRED)
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET libavformat libavcodec libavutil)
endif()
if(RK3588_ENABLE_MPP)
# Prefer user-provided lib path; otherwise search common locations including rknpu2 prebuilts.
find_library(RK_MPP_LIB rockchip_mpp
HINTS
${RK_MPP_LIB_PATH}
${RK_MPP_ROOT}/build
${RK_MPP_ROOT}/lib
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/aarch64
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/armhf
NO_DEFAULT_PATH
)
if(NOT RK_MPP_LIB)
find_library(RK_MPP_LIB rockchip_mpp)
endif()
if(NOT RK_MPP_LIB)
message(WARNING "MPP enabled but rockchip_mpp library not found; disable RK3588_ENABLE_MPP or set RK_MPP_LIB_PATH")
endif()
endif()
add_library(input_rtsp SHARED input_rtsp/input_rtsp_node.cpp)
target_include_directories(input_rtsp PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party)
target_link_libraries(input_rtsp PRIVATE project_options Threads::Threads)
if(RK3588_ENABLE_FFMPEG)
target_compile_definitions(input_rtsp PRIVATE RK3588_ENABLE_FFMPEG)
target_include_directories(input_rtsp PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(input_rtsp PRIVATE PkgConfig::FFMPEG)
endif()
if(RK3588_ENABLE_MPP AND RK_MPP_LIB)
target_compile_definitions(input_rtsp PRIVATE RK3588_ENABLE_MPP)
target_include_directories(input_rtsp PRIVATE
${RK_MPP_ROOT}/inc
${RK_RKNN_ROOT}/examples/3rdparty/mpp/include
)
target_link_libraries(input_rtsp PRIVATE ${RK_MPP_LIB})
endif()
set_target_properties(input_rtsp PROPERTIES
OUTPUT_NAME "input_rtsp"
LIBRARY_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
)
add_library(publish SHARED publish/publish_node.cpp)
target_include_directories(publish PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party)
target_link_libraries(publish PRIVATE project_options Threads::Threads)
set_target_properties(publish PROPERTIES
OUTPUT_NAME "publish"
LIBRARY_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
)
install(TARGETS input_rtsp publish
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/rk3588-media-server/plugins
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/rk3588-media-server/plugins
)