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.

216 lines
7.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

cmake_minimum_required(VERSION 3.15.0)
project(stitch VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 17) # 或更高版本
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# /utf-8 选项:将源文件视为 UTF-8 编码,并将字符串文字存储为 UTF-8。
add_compile_options(
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
)
# 可执行文件输出路径
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Bin)
IF(WIN32)
# ======== OpenCV 配置 ========
set(OpenCV_DIR "C:/lib/opencv455/build/x64/vc14/lib")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
link_libraries(${OpenCV_LIBS})
# ======== Ceres 配置 ========
set(Ceres_DIR ${CMAKE_SOURCE_DIR}/3rdParty/ceres_2.2)
set(Ceres_INCLUDE_DIR
${Ceres_DIR}/include
${Ceres_DIR}/include/ceres
${Ceres_DIR}/include/eigen3
${Ceres_DIR}/include/eigen3/Eigen
${Ceres_DIR}/include/gflags
${Ceres_DIR}/include/glog)
include_directories(${Ceres_INCLUDE_DIR})
set(CERES_LIBRARIES
"${Ceres_DIR}/lib/ceres.lib"
"${Ceres_DIR}/lib/gflags.lib"
"${Ceres_DIR}/lib/glog.lib"
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CERES_LIBRARIES
"${Ceres_DIR}/lib/ceres-debug.lib"
"${Ceres_DIR}/lib/gflags_debug.lib"
"${Ceres_DIR}/lib/glogd.lib"
)
endif()
ELSE()
# ======== OpenCV 配置 ========
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
link_libraries(${OpenCV_LIBS})
# ======== Ceres 配置 ========
find_package(Ceres REQUIRED)
include_directories(${Ceres_INCLUDE_DIR})
ENDIF()
# ======== Ceres 配置 ========
# 拼接算法库设置
SET(LIB_STITCH GuideStitch)
SET(LIB_STITCH_STATIC GuideStitchStatic)
add_subdirectory(stitch)
include_directories(tests)
# 测试用例1
add_executable(stitch tests/cpp/main.cpp "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_libraries(stitch ${LIB_STITCH})
# 测试用例2
add_executable(stitch_DJ "tests/cpp/DJ/ProcDJ.cpp" "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_libraries(stitch_DJ ${LIB_STITCH})
# 测试用例3
add_executable(stitch_Fea "tests/cpp/feaStitchTest.cpp" "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_libraries(stitch_Fea ${LIB_STITCH})
# 测试用例4
add_executable(stitch_Genaral "tests/cpp/stitch_Genaral.cpp" "tests/cpp/utils.cpp" "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_libraries(stitch_Genaral ${LIB_STITCH})
#S732
add_executable(stitch_S732_VL "tests/cpp/S732/stitch_S732.cpp" "tests/cpp/S732/S732.h" "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_libraries(stitch_S732_VL ${LIB_STITCH} ${OpenCV_LIBS})
# 测试用例5:s732 UDP
IF(WIN32)
# ======== FFMPEG配置 ========
set(FFMPEG_DIR "./3rdParty/ffmpeg4")
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_DIR}/include)
set(FFMPEG_LIBS_DIR ${FFMPEG_DIR}/lib/)
include_directories(${FFMPEG_DIR})
include_directories(${FFMPEG_INCLUDE_DIRS})
set(FFMPEG_LIBRARIES "avcodec" "avformat" "avutil" "swscale" "swresample")
add_executable(stitch_udp "tests/cpp/S732/stitch_udp.cpp" "tests/cpp/S732/decodedata.h" "tests/cpp/S732/decodedata.cpp" "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_directories(stitch_udp PUBLIC ${FFMPEG_LIBS_DIR})
target_include_directories(stitch_udp PUBLIC ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(stitch_udp ${LIB_STITCH} ${FFMPEG_LIBRARIES} ${OpenCV_LIBS})
ELSE()
set(FFMPEG_DIR /usr/local/ffmpeg4)
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_DIR}/include)
set(FFMPEG_LIBS_DIR ${FFMPEG_DIR}/lib)
set(FFMPEG_LIBRARIES "avdevice" "avcodec" "avformat" "avfilter" "avutil" "swscale" "swresample")
include_directories(${FFMPEG_INCLUDE_DIRS})
add_executable(stitch_udp "tests/cpp/S732/stitch_udp.cpp" "tests/cpp/S732/decodedata.h" "tests/cpp/S732/decodedata.cpp" "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_directories(stitch_udp PUBLIC ${FFMPEG_LIBS_DIR})
target_include_directories(stitch_udp PUBLIC ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(stitch_udp ${LIB_STITCH} ${FFMPEG_LIBRARIES} ${OpenCV_LIBS})
ENDIF()
# 格式转换
#add_subdirectory(convert)
# 测试用例5:s7215 ts码流
IF(WIN32)
# ======== FFMPEG配置 ========
set(FFMPEG_DIR "./3rdParty/ffmpeg4")
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_DIR}/include)
set(FFMPEG_LIBS_DIR ${FFMPEG_DIR}/lib/)
include_directories(${FFMPEG_DIR})
include_directories(${FFMPEG_INCLUDE_DIRS})
set(FFMPEG_LIBRARIES "avdevice" "avcodec" "avformat" "avutil" "swscale" "swresample")
# == Qt
set(Qt_DIR "C:/Qt/5.15.2/msvc2015_64")
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Widgets )
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets )
find_package(Qt5 REQUIRED COMPONENTS PrintSupport)
set(TS_FILES QGuideArith_zh_CN.ts)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
add_executable(stitch_S7215ts "tests/cpp/S7215/TsDecoder.hpp" "tests/cpp/S7215/TsPacker.hpp" "tests/cpp/S7215/stitch_S7215.cpp" "tests/cpp/S7215/Arith_zhryp.cpp" "tests/cpp/S7215/Arith_zhryp.h")
target_link_directories(stitch_S7215ts PUBLIC ${FFMPEG_LIBS_DIR})
target_include_directories(stitch_S7215ts PUBLIC ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(stitch_S7215ts ${LIB_STITCH} ${FFMPEG_LIBRARIES} ${OpenCV_LIBS} Qt${QT_VERSION_MAJOR}::Core)
ELSE()
# ======== Qt5 配置 ========
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets)
message(STATUS "QT_VERSION_MAJOR: ${QT_VERSION_MAJOR}")
message(STATUS "Qt5_FOUND: ${Qt5_FOUND}")
message(STATUS "Qt5_VERSION: ${Qt5_VERSION}")
# 启用Qt的MOC、UIC、RCC自动处理
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# ======== FFMPEG配置 ========
set(FFMPEG_DIR /usr/local/ffmpeg4)
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_DIR}/include)
set(FFMPEG_LIBS_DIR ${FFMPEG_DIR}/lib)
set(FFMPEG_LIBRARIES "avdevice" "avcodec" "avformat" "avfilter" "avutil" "swscale" "swresample")
include_directories(${FFMPEG_INCLUDE_DIRS})
# ======== 构建 stitch_S7215ts 可执行文件 ========
add_executable(stitch_S7215ts
"tests/cpp/S7215/TsDecoder.hpp"
"tests/cpp/S7215/TsPacker.hpp"
"tests/cpp/S7215/stitch_S7215.cpp"
"tests/cpp/S7215/Arith_zhryp.cpp"
"tests/cpp/S7215/Arith_zhryp.h"
)
target_include_directories(stitch_S7215ts PUBLIC ${FFMPEG_INCLUDE_DIRS})
target_link_directories(stitch_S7215ts PUBLIC ${FFMPEG_LIBS_DIR})
# CMake 默认会自动将 target_link_directories 的路径添加到 RPATH
# 同时也会自动添加 EXECUTABLE_OUTPUT_PATH (Bin) 到 RPATH
# 但可能会包含 anaconda 路径,导致 GLib 版本冲突
# 明确设置 RPATH排除 anaconda 路径,优先使用系统库
set_target_properties(stitch_S7215ts PROPERTIES
BUILD_RPATH "${EXECUTABLE_OUTPUT_PATH};${FFMPEG_LIBS_DIR};/usr/lib/x86_64-linux-gnu;/lib/x86_64-linux-gnu"
INSTALL_RPATH "${EXECUTABLE_OUTPUT_PATH};${FFMPEG_LIBS_DIR};/usr/lib/x86_64-linux-gnu;/lib/x86_64-linux-gnu"
)
# 链接所有库
target_link_libraries(stitch_S7215ts
${LIB_STITCH}
${FFMPEG_LIBRARIES}
${OpenCV_LIBS}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
)
ENDIF()