Getting Started with CMake
find_package to locate the libraries and header files shipped with Qt Quick Ultralite. You can use the
target_link_libraries command to build your Qt Quick Ultralite-based application with these libraries and header files. This command automatically adds the appropriate include directories, compile definitions, and libraries.
cmake_minimum_required (VERSION 3.15) find_package(Qul) add_executable(example) target_link_libraries(example Qul::QuickUltralite)
Then add your source files. Add the QML source files using the qul_target_qml_sources command, and the C++ files that define the exported classes using the qul_target_generate_interfaces command. During the build the QML sources are translated to C++ and then compiled. Descriptions of the exported types in interface headers are made available to the QML code. See Integrating C++ code with QML for details.
target_sources(example PRIVATE example.cpp) qul_target_qml_sources(example ExampleView.qml) qul_target_generate_interfaces(example example.h)
If you want the application to be translated, set up translations using qul_target_embed_translations. This creates a
update_translations target for generating and updating the listed
.ts files based on the translated strings in the QML sources, and embed those translations in the binary. See Internationalization and Localization with Qt Quick Ultralite for details.
qul_target_embed_translations(example translation.nb_NO.ts translation.lv_LV.ts)
Finally, use app_target_setup_os to do additional setup for the OS depending on the value of the OS variable. This command links the right platform library and performs additional actions, such as compiling and linking FreeRTOS sources.
set(OS "BareMetal") app_target_setup_os(example)
Build the project by running
cmake on the directory with the
CMakeLists.txt file and command-line options to choose the platform to build for. For example, to build for the STM32F769I-Discovery board:
cmake <source_directory> -DCMAKE_TOOLCHAIN_FILE=<qul_directory>/cmake/toolchain/armgcc.cmake -DQUL_PLATFORM=STM32F769I-DISCOVERY-baremetal
Available under certain Qt licenses.
Find out more.