Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CMakeLists includeT Qt5::QML does not work

This is my CMakelists.txt file.

cmake_minimum_required(VERSION 3.0.2)
project(osm_map)
find_package(catkin REQUIRED COMPONENTS rviz)

find_package(Qt5 COMPONENTS Widgets REQUIRED)
set(QT_LIBRARIES Qt5::Widgets Qt5::Qml)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set(SRC_FILES
  src/core.cpp
)

add_library(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})

When I try to compile my project with catkin_make -Wno-dev --only-pkg-with-deps osm_map, it seems to find every module of QT (I also tested others not shown below) but not QML. Error message:

CMake Error at osm_map/CMakeLists.txt:53 (target_link_libraries):
  Target "osm_map" links to:

    Qt5::Qml

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

QT QML is installed on my system and the path /usr/include/x86_64-linux-gnu/qt5/QtQml and includes the necessary headers. And idea why I could do? The find_package call for QT is supposed to find all libaries and headers shipped with QT, maybe that is the part that is not working properly for QML?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The problem is in your

find_package(Qt5 COMPONENTS Widgets REQUIRED)

here you asked CMake that you wanted the Widgets component of Qt5 but then you tell it to link with Qml which you did not ask for.

You should change this to the following:

find_package(Qt5 COMPONENTS Widgets Qml REQUIRED)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading