1

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?

amir sharifi
  • 31
  • 1
  • 4
  • If you want to hint CMake about location of packages, searched by `find_package()`, set `CMAKE_PREFIX_PATH` variable, as described in that answer: https://stackoverflow.com/a/34797156/3440745. – Tsyvarev May 03 '18 at 17:32
  • 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 May 03 '18 at 18:17

1 Answers1

1

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)
luffy
  • 2,246
  • 3
  • 22
  • 28