catkin之cmakefiles.txt格式

5 篇文章 0 订阅
  • Required CMake Version (cmake_minimum_required)

  • Package Name (project())

  • Find other CMake/Catkin packages needed for build (find_package())

  • Message/Service/Action Generators (add_message_files(), add_service_files(), add_action_files())

  • Invoke message/service/action generation (generate_messages())

  • Specify package build info export (catkin_package())

  • Libraries/Executables to build (add_library()/add_executable()/target_link_libraries())

  • Tests to build (catkin_add_gtest())

  • Install rules (install())


版本
cmake_minimun_required(version 2.8.3)
包含项目名
project(beginner_tutorials)
寻找依赖的包
find_package(catkin REQUIRED)    至少依赖catkin(必要的)
以下可选包元素
find_package(catkin REQUIRED COMPONENTS rospy roscpp std_msgs)
上述写法的另一种形式
find_package(catkin REQUIRED)
find_package(rospy REQUIRED)
find_package(roscpp REQUIRED)
find_package(std_msgs REQUIRED)

if you using C++ and Boost:
find_package(Boost REQUIRED COMPONENTS thread)
catkin包 是cmake的宏
catkin_package()有五个可选属性
catkin_package(
   INCLUDE_DIRS include
   LIBRARIES ${PROJECT_NAME}
   CATKIN_DEPENDS roscpp nodelet  # 比较重要的一条属性
   DEPENDS eigen opencv)
输出目标文件名替换
set_target_properties(rviz_image_view
                      PROPERTIES OUTPUT_NAME image_view
                      PREFIX "")
从rviz_image_view修改为image_view
设置自己的输出目录
set_target_properties(python_module_library
  PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION})
include_directories()

The argument to include_directories should be the *_INCLUDE_DIRS variables generated by your find_package calls and any additional directories that need to be included. If you are using catkin and Boost,即

catkin_INCLUDE_DIRS    Boost_INCLUDE_DIRS

include_directories(include  ${catkin_INCLUDE_DIRS}    ${Boost_INCLUDE_DIRS})

可执行目标必须建立


add_executable(myProgram src/main.cpp src/some_file.cpp src/another_file.cpp)
                                   项目名  +   源文件

#    add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS})

       add_library(moo src/moo.cpp)

链接 target_link_libraries()

语法:  target_link_libraries(<executableTargetName>, <lib1>, <lib2>, ... <libN>)

example:


add_executable(foo src/foo.cpp)
add_library(moo src/moo.cpp)
target_link_libraries(foo moo)  -- This links foo against libmoo.so

for python 参考:http://docs.ros.org/api/catkin/html/howto/format2/installing_python.html

Installing Python Executable Scripts

catkin_install_python(PROGRAMS scripts/myscript
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值