ros2 CMakeLists.txt与packages.xml写法

:尽量使用ament_cmake_auto来编写cmakelists.txt文件,依赖的程序包在packages.xml文件中用nav_msgs的形式声明,一些找不到的动态链接库可以用target_link_libraries的方式书写

cmake_minimum_required(VERSION 3.5)
project(nolinear_mpc_control)
if(NOT CMAKE_CXX_STANDARD)
    set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    add_compile_options(-Wall -Wextra -Wpedantic)
endif()

add_definitions(-fPIC)

#find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
find_package(ament_cmake_auto REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(ackermann_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(chassis_control REQUIRED)

#find_package(rosidl_default_generators REQUIRED)
ament_auto_find_build_dependencies()

ament_auto_add_executable(nolinearMPCNode 
  src/MPCNode.cpp
  src/NolinearMPC.cpp
)
target_link_libraries(nolinearMPCNode 
  ipopt
)
ament_auto_package ()



  nolinear_mpc_control
  0.0.0
  TODO: Package description
  zhangying
  TODO: License declaration

  ament_cmake
  
  std_msgs
  chassis_control
  nav_msgs
  tf2_ros
  ackermann_msgs
  eigen3
  ipopt

  ament_lint_auto
  ament_lint_common
  
  
    ament_cmake
  

你可能感兴趣的:(自动驾驶,ros2,cmakelists.txt)