Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake doesn't find Qt5QuickCompiler

Tags:

cmake

qt

qtquick2

I'm trying to build a Qt Quick Controls application with CMake. I use the following documentation:

http://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html

When running CMake, I'm getting this error:

By not providing "FindQt5QuickCompiler.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "Qt5QuickCompiler", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5QuickCompiler"
  with any of the following names:

    Qt5QuickCompilerConfig.cmake
    qt5quickcompiler-config.cmake

at this line:

FIND_PACKAGE(Qt5QuickCompiler)

Obviously CMake doesn't find Qt5QuickCompiler. I checked in my Qt folder (C:\Qt) but it's not there. Yet I could run this application with QMake.

What do I need to set in order to find Qt5QuickCompiler?

like image 413
Grégoire Borel Avatar asked Feb 08 '23 19:02

Grégoire Borel


2 Answers

I just stumbled upon the same issue with Qt 5.12 under Linux. The documentation under https://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html currently seems to be wrong.

Use QuickCompiler after COMPONENTS in the Qt5 find_package instead of trying to add it via find_package(Qt5QuickCompiler). Adapting the example from the link, use

find_package(Qt5 COMPONENTS Quick Core Network QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)

instead of

find_package(Qt5 COMPONENTS Quick Core Network)
find_package(Qt5QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)
like image 192
rbr Avatar answered Feb 15 '23 23:02

rbr


The error is pretty clear: CMake doesn't have a module for the Qt5QuickCompiler to find it. It just doesn't know what it is. I've just checked the corresponding cmake folder and it doesn't have that file. I'm not sure what that Qt documentation page is talking about but there is no such a file in the CMake distribution. Maybe Qt sources have this file somewhere?

like image 34
ixSci Avatar answered Feb 16 '23 00:02

ixSci