C

Building with CMake

If you are building your application using the CMake build tool, then you can easily use the QtQuick compiler as well. The integration provided works similar to the qmake integration:

  • Convert your application to use the Qt Resource System for loading your .qml , .js files and qmldir files.
  • Call find_package with Qt5QuickCompiler
  • Replace the use of qt5_add_resources with qtquick_compiler_add_resources if you want to build with support for the Qt Quick Compiler. The integration will ignore any .qrc files that do not contain any files relevant for the compiler.

The following example CMakeLists.txt shows the conversion from a project with regular resources to one that enables the use of the Qt Quick Compiler.

Before the conversion:

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

After the conversion to use the Qt Quick Compiler:

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

Available under certain Qt licenses.
Find out more.