1
votes

I have a QML project want to run with Cmake I have Qt 5.10.1 its Support QtQuick 2.10 and QtQuickControl 2.3
But when I build my project this error show

module "QtQuick" version 2.9 is not installed

I use this code to import QtQuick

find_package(Qt5Quick REQUIRED)

But I think this not search at my Home directory that i install my Qt because when I decrease version of QtQuick to 2.5 in my main.qml file the error solve and this error show

module "QtQuick.Controls" version 2.2 is not installed

Question is: how Can import my Home directory QtQuick and QtQuickControls in my Cmake or any other idea?

1
If you want to hint CMake about location of packages, searched by find_package(), set CMAKE_PREFIX_PATH variable, as described in that answer: stackoverflow.com/a/34797156/3440745. - Tsyvarev
I know that i use that what there isnt any CMakeList in QtQuick or QtQuickControl in Qt 5.10.1 to import that list(APPEND CMAKE_PREFIX_PATH "/home/amir/Qt5.10.1/5.10.1/Src/qtquickcontrols2/tests/auto/cmake") - amir sharifi

1 Answers

1
votes

Did you also link it to your executable? The following works for me:

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)  

find_package(Qt5Core)
find_package(Qt5Quick REQUIRED)
find_package(Qt5Qml REQUIRED)

add_executable (myApp ${SOURCES})

target_link_libraries(myApp Qt5::Core)
target_link_libraries(myApp Qt5::Qml)
target_link_libraries(myApp Qt5::Quick)