linux知识点——CMakeLists.txt常见指令补充

cmake_minimum_required(VERSION 2.8.12)
# 指定cmake最小版本
project(multi_lidar_calibration)
#定义工程名
add_compile_options(-std=c++11)
#编译选项,使用C++11编译标准
set(CMAKE_BUILD_TYPE Release)
#设置编译类型,Release模式
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
#为后面作准备:find_package(Glog  REQUIRED)  # Glog --> FindGlog.cmake
#对于安装到本地的库(头文件所在目录/usr/local/include,库的位置位于/usr/local/lib.),一些大型的开源库,例如OpenCV,在输入:find_package(OpenCV REQUIRED),他就可以自己就能找到库,,因为它们已经自带.cmake文件了。
#对于一些不知名的库,或者自己编译的库,你直接使用find_package(<NAME> REQUIRED)是找不到库的。
#所以加入set(...)上面的这句话决定我们在哪儿去找.cmake文件,找到cmake文件,文件内容就相当于是子函数,里面的东西可以直接引用。PROJECT_SOURCE_DIR当前工程的路径。

#参考:https://blog.csdn.net/qq_46515446/article/details/121498619


# catkin
find_package(catkin REQUIRED COMPONENTS
             roscpp
             std_msgs
             sensor_msgs
             geometry_msgs
             message_filters
             tf 
             tf_conversions)
# ???ros
include_directories(include ${catkin_INCLUDE_DIRS})
#向工程添加多个指定的头文件搜索路径

# boost
find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
include_directories(${Boost_INCLUDE_DIRS})
# 为使用boost库,需要使用find_package命令找到它,然后再引入头文件${Boost_INCLUDE_DIRS}和库文件(boost没有库文件,跟sophus一样)

# pcl
find_package(PCL 1.7 REQUIRED)
#安装的版本要一致
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})
# ???pcl
# 为使用PCL库,需要使用find_package命令找到它,然后再引入头文件${PCL_INCLUDE_DIRS}和库文件${PCL_LIBRARIES}

# opencv
find_package(OpenCV 3.3 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
#include_directories(${OpenCV_LIBRARIES})

# glog and gflags
find_package(Glog  REQUIRED)
find_package(Gflags REQUIRED)              


catkin_package(CATKIN_DEPENDS
               std_msgs
               sensor_msgs
               geometry_msgs)
# ???

# library
add_library(multi_lidar_calibrator_lib SHARED
        include/dual_lidar_calibrator.h
        include/five_lidar_calibrator.h
        include/lidar_ground_calibrator.h
        src/dual_lidar_calibrator.cpp
        src/five_lidar_calibrator.cpp)
#生成库文件(SHARED共享库/动态库.so库,不要SHARED/加上STATIC就是静态库.a库)
target_link_libraries(multi_lidar_calibrator_lib
        ${catkin_LIBRARIES}
        ${PCL_LIBRARIES}
        ${OpenCV_LIBRARIES}
        ${GLOG_LIBRARIES})
#为动态库添加需要链接的共享库
#!!!


# executable        
add_executable(dual_lidar_calibrator
               node/dual_lidar_calibrator_node.cpp)
#生成可执行文件
target_link_libraries(dual_lidar_calibrator
                      multi_lidar_calibrator_lib)
#为target添加需要链接的共享库
                      
add_executable(five_lidar_calibrator_node
        node/five_lidar_calibrator_node.cpp)
target_link_libraries(five_lidar_calibrator_node
        multi_lidar_calibrator_lib)

add_executable(lidar_ground_calibrator_node
        node/lidar_ground_calibrator_node.cpp)
target_link_libraries(lidar_ground_calibrator_node
        multi_lidar_calibrator_lib)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值