视觉SLAM十四讲——CMakeLists.txt语句规范

#声明cmake最低版本要求
cmake_minimum_required( VERSION 2.8 )

#声明工程
project( test )

#设置编译模式
set( CMAKE_DEBUG_TYPE "Debug" )
#设置C++11标准
set( CMAKE_CXX_FLAGS "-std=c++11" )

#添加可执行程序
add_executable( test test.cpp )

#添加自己的库add_library( 库名 程序名 )
add_library( libMy libMy.cpp )
#共享库
add_library( libMy SHARED libMy.cpp )
#将库链接到可执行程序target_link_libraries( 可执行程序名 库名 )
target_link_libraries( test libMy )

#添加Eigen库
include_directories( "/usr/local/include/eigen3" )
#或include_directories( "/usr/include/eigen3" )

#添加Pangolin库;可视化
find_package( Pangolin REQUIRED )
include_diectories( ${Pangolin_INCLUDE_DIRS} )
target_link_libraries( test ${Pangolin_LIBRARIES} )

#添加Sophus库;李群和李代数
find_package( Sophus REQUIRED )
include_directories( ${Sophus_INCLUDE_DIRS} )
target_link_libraries( test ${Sophus_LIBRARIES} fmt )
#fmt 很重要,不写会报错In function `fmt::v8::detail::error_handler::on_error(char const*)

#使用OpenCV库;图像处理
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( test ${OpenCV_LIBRARIES} )

#添加子程序
add_subdirectory( test_sub1 )

你可能感兴趣的:(视觉SLAM,slam)