1.OpenCV
# 添加OpenCV头文件
find_package(OpenCV 3.0 REQUIRED)
include_directories(${OpenCV_INCLDUE_DIRES})
add_executable( name cpp )
target_link_libraries(name ${OpenCV_LIBS})
使用多版本OpenCV,在写CmakeLists.txt要注意,如果只有一个版本的OpenCV,我们一般直接使用FIND_PACKAGE(OpenCV REQUIRED),如果现在要使用的是默认安装的OpenCV3,则使用上面的指令就足够了。如果现在要使用的是我们自己指定路径的opencv-4.2.0,则在上面指令前面加上如下指令:
set(CMAKE_PREFIX_PATH "/usr/local/opencv4")
2.Eigen
# 添加Eigen头文件
include_directories( "/usr/include/eigen3" )
add_executable( name cpp )
3.Pangolin
# 添加Pangolin头文件
include_directories( "/usr/include" )
find_package(Pangolin REQUIRED)
include_directories(${Pangolin_INCLDUE_DIRES})
add_executable( name cpp )
target_link_libraries(name ${Pangolin_LIBRARIES})
4.ceres
# 添加cmake模块以使用ceres库
list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules )
# 寻找Ceres库并添加它的头文件
find_package( Ceres REQUIRED )
include_directories( ${CERES_INCLUDE_DIRS} )
add_executable( name cpp )
target_link_libraries( name ${CERES_LIBRARIES})
5.g20
# 添加cmake模块以使用g2o库
list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules )
# 寻找G2O
find_package( G2O REQUIRED )
include_directories(
${G2O_INCLUDE_DIRS}
"/usr/include/eigen3"
)
add_executable( name cpp )
# 与G2O和OpenCV链接
target_link_libraries( name g2o_core g2o_stuff)
6.DBoW3
# 寻找DBoW3
set( DBoW3_INCLUDE_DIRS "/usr/local/include" )
set( DBoW3_LIBS "/usr/local/lib/libDBoW3.so" )
add_executable( name cpp )
# 与DBoW3和OpenCV链接
target_link_libraries( name ${DBoW3_LIBS})
7.Sophus
find_package(Sophus REQUIRED)
include_directories( ${Sophus_INCLDUE_DIRES})
add_executable( name cpp )
# 与DBoW3和OpenCV链接
target_link_libraries( name ${Sophus_LIBRARIES}