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}
)
QT与ROS2的cmake配置(2番外篇)
于 2024-06-26 19:10:22 首次发布