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.

130 lines
3.9 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.

# 获取编译时间
string(TIMESTAMP COMPILE_TIME 20%y_%m_%d-%H.%M.%S)
set(build_time ${COMPILE_TIME})
# 获取当前版本信息
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h)
add_definitions(-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING)
add_definitions(-DGLOG_USE_GLOG_EXPORT)
add_definitions(-DGLOG_NO_ABBREVIATED_SEVERITIES)
# cuda 加速支持
SET(ENABLE_CUDA FALSE)
IF(ENABLE_CUDA)
add_definitions(-DENABLE_CUDA)
# 开启cmake的cuda支持
enable_language(CUDA)
set(CUDA_ARCHITECTURES "50;52;60;70;75;80")
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 70 75 80)
# 注意配置cuda的运行时库设置
if(WIN32)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler=/MDd")
elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler=/MD")
elseif(CMAKE_BUILD_TYPE MATCHES "Release")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler=/MD")
else()
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler=/MD")
endif()
endif(WIN32)
ENDIF(ENABLE_CUDA)
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
# 配置openmp
find_package(OpenMP REQUIRED)
# 配置GDAL
IF(NOT WIN32)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GDAL REQUIRED gdal)
include_directories(${GDAL_INCLUDE_DIRS})
link_directories(${GDAL_LIBRARY_DIRS})
ENDIF()
# 公共头文件(放置在最前面,所有后面定义的模块才都能找到)
SET(ArithTrkPubInc public_include)
include_directories(${ArithTrkPubInc}) # 引入算法公共头文件
set(ArithSrcDIR_MAIN "src") # 库源文件路径
set(ArithSrcDIR_LOG "src/Log") # 日志文件路径
set(ArithSrcDIR_DeepSort "src/deepsort/src") # deepsort
# 使用当前目录、Common目录源码构建
file(GLOB libsrcs ${ArithSrcDIR_MAIN}/FrontStitch/mapKernel.cu
${ArithSrcDIR_MAIN}/*.cpp ${ArithSrcDIR_MAIN}/*.c ${ArithSrcDIR_MAIN}/*.h ${ArithSrcDIR_MAIN}/*.hpp
${ArithSrcDIR_MAIN}/FrontStitch/*.h ${ArithSrcDIR_MAIN}/FrontStitch/*.cpp
${ArithSrcDIR_MAIN}/FeaStitch/*.h ${ArithSrcDIR_MAIN}/FeaStitch/*.cpp
)
file(GLOB CommonSrc ${ArithSrcDIR_MAIN}/utils/*.cpp ${ArithSrcDIR_MAIN}/utils/*.c ${ArithSrcDIR_MAIN}/utils/*.h ${ArithSrcDIR_MAIN}/utils/*.hpp)
file(GLOB LogSrc ${ArithSrcDIR_LOG}/*.cpp ${ArithSrcDIR_LOG}/*.c ${ArithSrcDIR_LOG}/*.h ${ArithSrcDIR_LOG}/*.hpp)
file(GLOB DeepSortSrc ${ArithSrcDIR_DeepSort}/*.cpp ${ArithSrcDIR_DeepSort}/*.c)
add_library(${LIB_STITCH} SHARED ${libsrcs} ${CommonSrc} ${LogSrc} ${DeepSortSrc}) # 构建算法库
# 设置包含路径
target_include_directories(${LIB_STITCH} PUBLIC
${Ceres_INCLUDE_DIR}
${ArithTrkPubInc}
${ArithSrcDIR_MAIN}
${ArithSrcDIR_MAIN}/utils
${ArithSrcDIR_MAIN}/Log
${ArithSrcDIR_MAIN}/deepsort/include
${ArithSrcDIR_MAIN}/FeaStitch
${ArithSrcDIR_MAIN}/FrontStitch
)
# 添加GDAL头文件路径Linux
IF(NOT WIN32)
target_include_directories(${LIB_STITCH} PUBLIC ${GDAL_INCLUDE_DIRS})
ENDIF()
link_directories(${Ceres_DIR}/lib)
# 算法库链接
target_link_libraries(${LIB_STITCH}
OpenMP::OpenMP_CXX
${OpenCV_LIBS}
${CERES_LIBRARIES}
${CUDA_LIBRARIES}
)
# 链接GDAL库Linux
IF(NOT WIN32)
target_link_libraries(${LIB_STITCH} ${GDAL_LIBRARIES})
ENDIF()
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Bin) # 输出算法库路径
# python 绑定
add_subdirectory(py/pybind11)
pybind11_add_module(
UStitcher # 模块名
py/API_UnderStitch_binding.cpp # 主绑定文件
py/public_binding.cpp # 公共结构绑定
# cvbind.h 是头文件,不需要单独编译
)
target_include_directories(UStitcher PUBLIC src public_include py)
target_link_libraries(UStitcher PUBLIC
${LIB_STITCH} )