I'm using cmake to compile a Qt project (which also uses catkin, since this is really a ROS project but I don't think the problem is related to this). Everything compiled and worked fine until I started to use images and added a qrc file to handle them. When I run cmake I get this error:
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.
My CMakeList file is like this:
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})
the qrc file is:
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/images">
<file>images/slide-groove.png</file>
<file>images/slide-handle.png</file>
</qresource>
</RCC>
I'm using cmake 2.8.12.2 on an ubuntu 14.04 machine.