使用资源和ROS(Catkin_Make)用CMake编译一个Qt项目

Compiling a Qt project with CMake using resources and ROS (catkin_make)(使用资源和ROS(Catkin_Make)用CMake编译一个Qt项目)

本文介绍了使用资源和ROS(Catkin_Make)用CMake编译一个Qt项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cmake编译一个Qt项目(它也使用了柳絮,因为这实际上是一个ROS项目,但我认为问题与此无关)。在我开始使用图像并添加了一个QRC文件来处理它们之前,一切都很好地编译和运行。当我运行cmake时,收到以下错误:

make[2]: *** No rule to make target `/home/myname/development/ros/src/dls_gui/images/slide-groove.png', needed by `dls_gui/qrc_dls_gui.cpp'.  Stop.

我的CMakeList文件如下:

cmake_minimum_required(VERSION 2.8.11)
project(dls_gui)

# Find the QtWidgets library
find_package(Qt5Widgets)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# catkin related
find_package(catkin REQUIRED COMPONENTS roscpp sensor_msgs urdf)

include_directories(${catkin_INCLUDE_DIRS} include)

# source, header and resources files list
set(CPP_SOURCES src/main.cpp src/mainwindow.cpp src/basewidget.cpp src/rosQtNode.cpp src/joints_sliders.cpp src/superslider.cpp)
set(CPP_HDRS include/mainwindow.h include/basewidget.h include/rosQtNode.hpp include/joints_sliders.hpp include/superslider.hpp)
set(QRC_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dls_gui.qrc)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

## Declare a catkin package
catkin_package()

# Add the include directories for the Qt 5 Widgets module to
# the compile lines.
include_directories(${Qt5Widgets_INCLUDE_DIRS})

# Use the compile definitions defined in the Qt 5 Widgets module
add_definitions(${Qt5Widgets_DEFINITIONS})

# Generate headers from ui files
qt5_wrap_ui(UIS_HDRS src/mainwindow.ui)

# Generate moc files from cpp
qt5_wrap_cpp(MOC_SOURCES ${CPP_SOURCES} ${CPP_HDRS})

# Generate resources 
qt5_add_resources(RESOURCES_RCC ${RESOURCE})

# Add compiler flags for building executables (-fPIE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} -std=c++11")

## Ros include dirs
include_directories(include ${catkin_INCLUDE_DIRS})

# Tell CMake to create the helloworld executable
add_executable(dls_gui ${CPP_SOURCES} ${UIS_HDRS} ${MOC_SOURCES} ${QRC_RESOURCES})
add_executable(testRos src/testRos.cpp)
qt5_use_modules(dls_gui Widgets)

#Link the helloworld executable to the Qt 5 widgets library.
target_link_libraries(dls_gui Qt5::Widgets ${catkin_LIBRARIES})

target_link_libraries(testRos ${catkin_LIBRARIES})

QRC文件为:

<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/images">
    <file>images/slide-groove.png</file>
    <file>images/slide-handle.png</file>
</qresource>
</RCC>

我在ubuntu 14.04计算机上使用的是cmake 2.8.12.2。

推荐答案

所以很明显,这是一个餐饮问题。我删除了catkin创建的构建目录,再次运行catkin_make,现在它可以编译了。

注意:我刚刚对cmake文件进行了少量编辑。我在So上复制错了一个。

这篇关于使用资源和ROS(Catkin_Make)用CMake编译一个Qt项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用资源和ROS(Catkin_Make)用CMake编译一个Qt项目

基础教程推荐