QT与ROS2的cmake配置(2番外篇)

cmake_minimum_required(VERSION 3.8)
project(village_wang)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Concurrent)
#下面的一定要打开否则会报错
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#设置源文件
set(SOURCE_FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/node_wang2/wang2.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/runnodes/runnodes.cpp
)
#设置头文件
set(HEADER_FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.h
    ${CMAKE_CURRENT_SOURCE_DIR}/runnodes/runnodes.h
)
#设置ui文件
qt5_wrap_ui(UI_FILES ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.ui)
#下面是默认的
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()

#设置可执行文件的源文件和ui文件(不太确定要不要加头文件)
add_executable(wang2_node  ${SOURCE_FILES} ${UI_FILES})

ament_target_dependencies(wang2_node rclcpp std_msgs)

target_link_libraries(wang2_node Qt5::Core Qt5::Widgets Qt5::Concurrent )

target_include_directories(wang2_node PRIVATE ${Qt5Widgets_INCLUDE_DIRS})

install(TARGETS
  wang2_node

  DESTINATION lib/${PROJECT_NAME}
)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值