常见CMakeLists.txt内容:
# 声明要求的cmake最低版本cmake_minimum_required( VERSION 2.8 )set( CMAKE_BUILD_TYPE "Debug" )# 声明一个cmake工程project( HelloSLAM )# 添加一个可执行程序# 语法: add_executable( 程序名 源代码文件 )add_executable( helloSLAM helloSLAM.cpp )# 编译、链接库add_library( hello libHelloSLAM.cpp ) # 静态库 .a# add_library( hello_shared SHARED libHelloSLAM.cpp ) # 共享库 .soadd_executable( useHello useHello.cpp )target_link_libraries( useHello hello_shared )# 如果只添加头文件include_directories("/usr/include/eigen3")
执行
mkdir buildcd buildcmake ..make
