I was using an old CMakeLists of a package based on QT4:
cmake_minimum_required(VERSION 2.8.0)
project(pol)
add_compile_options(-std=c++17)
find_package(catkin REQUIRED COMPONENTS qt_build roscpp sensor_msgs cv_bridge image_transport)
find_package(OpenCV REQUIRED)
include_directories(${catkin_INCLUDE_DIRS})
catkin_package()
rosbuild_prepare_qt4(QtCore QtGui) # Add the appropriate components to the component list here
file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/pol/*.hpp)
QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
add_executable(pol ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
target_link_libraries(pol ${QT_LIBRARIES} ${catkin_LIBRARIES})
install(TARGETS pol RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
Now I'm trying to move to recent version of QT5, so I started like that:
cmake_minimum_required(VERSION 3.1.0)
project(pol)
add_compile_options(-std=c++17)
find_package(catkin REQUIRED COMPONENTS qt_build roscpp sensor_msgs cv_bridge image_transport)
find_package(OpenCV REQUIRED)
include_directories(${catkin_INCLUDE_DIRS})
catkin_package()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5 COMPONENTS Core Gui Widgets)
rosbuild_prepare_qt4(QtCore QtGui) # Add the appropriate components to the component list here
file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/fmf_qt/*.hpp)
QT5_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT5_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
include_directories(
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
add_executable(pol ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
target_link_libraries(pol Qt5::Widgets Qt5::Core ${QT_LIBRARIES} ${catkin_LIBRARIES})
install(TARGETS pol RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
Now I'm getting errors that I believe are due to my new CMakeLists such as
error: incomplete type ‘QImage’ used in nested name specifier
error: invalid use of incomplete type ‘class QImage’
The package is developed under ROS ubuntu 18.04 LTS and compiled with gcc 8.1 Do you know what's wrong with my new CMakeLists?
The package was working with my old CMakeLists!
EDIT:
I run cmake correctly:
cmake ../src -DCMAKE_INSTALL_PREFIX=../install -DCATKIN_DEVEL_PREFIX=../devel
But I get the errors when I run make
cmakeor when you invokemakeon the generated makefiles?makeI edited my post.cppcode, not in theCMakeLists.txt. (That is,CMakeLists.txtcould be bagged, but.cppis bugged too).