This commit is contained in:
cxh 2025-11-14 10:40:58 +08:00
parent df4e3317f4
commit 889a10e54d

View File

@ -1,21 +1,26 @@
cmake_minimum_required(VERSION 3.10)
# 便
project(rtsp_server)
#
set(APP_NAME "video_manager")
#
set(CONFIG_FILE "config.json")
project(${APP_NAME})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_definitions(GLIB_DISABLE_DEPRECATION_WARNINGS)
#
#
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
# GStreamer
# GStreamer
find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
#
# include
include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/third_party/include
@ -23,30 +28,32 @@ include_directories(
${GSTREAMER_INCLUDE_DIRS}
)
#
#
file(GLOB SRC_FILES src/*.cpp)
# project
add_executable(camera_to_rtsp ${SRC_FILES})
#
add_executable(${APP_NAME} ${SRC_FILES})
#
# lib
link_directories(
${GSTREAMER_LIBRARY_DIRS}
${CMAKE_SOURCE_DIR}/third_party/lib
)
#
target_link_libraries(camera_to_rtsp
target_link_libraries(${APP_NAME}
${GSTREAMER_LIBRARIES}
pthread
mp4v2
util
${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqttpp3.a
${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3a.a
${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3c.a
)
# config.json bin/
add_custom_command(TARGET camera_to_rtsp POST_BUILD
#
add_custom_command(TARGET ${APP_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/config.json
$<TARGET_FILE_DIR:camera_to_rtsp>/config.json
${CMAKE_SOURCE_DIR}/${CONFIG_FILE}
$<TARGET_FILE_DIR:${APP_NAME}>/${CONFIG_FILE}
)