C

Using a custom toolchain

By default, Qt Quick Ultralite supports ARM GCC, GHS, or IAR toolchains across the supported platforms. However, it is possible to use your own compiler in the project.

To configure Qt Quick Ultralite for your toolchain, follow these steps:

  1. Add a <YOUR_COMPILER>.cmake to lib\cmake\Qul\toolchain directory.
  2. Create <YOUR_COMPILER> directory under platform\boards\<MANUFACTURER_NAME>\<YOUR_PLATFORM>\cmake.
  3. Edit CMake configuration files in Qt Quick Ultralite

Adding <YOUR_COMPILER>.cmake to the project

Add the <YOUR_COMPILER>.cmake to the lib\cmake\Qul\toolchain directory. This file configures your toolchain for the project. You can also use existing toolchain configurations as a basis for your compiler configuration.

The following variables should be set in the file:

VariableDescription
CMAKE_SYSTEM_NAMEThe operating system CMake is building for. This must be set to Generic.
CMAKE_SYSTEM_PROCESSORThe processor CMake is building for. For example, if your target CPU is ARM CPU, set this to arm.
COMPILER_FOLDER_NAMETells Qt Quick Ultralite project what compiler directory should be used for the target platform. This must match the name of the compiler directory in platform\boards\<MANUFACTURER_NAME>\<YOUR_PLATFORM>\cmake or else you will get errors during configuration.
LINKER_SCRIPT_OPTIONThis is used in qul_platform_add_default_linker_script to tell linker what flags to use. If you are not using LINKER_SCRIPT_OPTION, this is not needed.
CMAKE_C_COMPILERPath to the C compiler.
CMAKE_CXX_COMPILERPath to the C++ compiler.
CMAKE_ASM_COMPILERPath to the assembly compiler. This is not needed if you do not have assembly files in you platform.
CMAKE_ARPath to the toolchain's archiver.
CMAKE_CXX_FLAGS_INITC++ compiler flags that are used in every configuration.
CMAKE_C_FLAGS_INITC compiler flags that are used in every configuration.
CMAKE_C_FLAGS_DEBUGC compiler flags that are used in debug configuration in addition to the flags used in CMAKE_C_FLAGS_INIT.
CMAKE_CXX_FLAGS_DEBUGC++ compiler flags that are used in debug configuration in addition to the flags used in CMAKE_CXX_FLAGS_INIT.
CMAKE_EXE_LINKER_FLAGS_INITLinker flags that are used in every configuration.

In addition, you also need to set a variable that can be used to identify your compiler:

SET(<YOUR_COMPILER> ON)

This is used in other CMake files to configure additional things if needed.

<YOUR_COMPILER> directory

Create a directory named <YOUR_COMPILER> (or the name you set to COMPILE_FOLDER_NAME in the previous step) for your toolchain in the platform\boards\<MANUFACTURER_NAME>\<YOUR_PLATFORM>\cmake directory, and add all required files mentioned in the "cmake directory" section.

CMake configuration files in Qt Quick Ultralite

Your toolchain may require some additional configuration in Qt Quick Ultralite.

The following files contain compiler-dependent configurations and might be worth checking out.

  • examples\CMakeLists.txt has compiler-dependent warning flags, such as Wall and Werror. If your compiler does not support already provided flags, add your own here.
  • platform\CMakeLists.txt If you are going to use same compiler on multiple platforms, it might be a good idea to write some common compilation options for Platform here.
  • src\CMakeLists.txt is used to build Core target. If your compiler has some specific arguments that must be taken into account, add them here.

    The file also includes configuration code for supported compilers. Check that your compiler can use the set parameters and modify the code if needed.

  • src\pngdecoders.cmake adds LodePNG based PNG decoder to Qt Quick Ultralite. If your compiler has some specific arguments that must be taken into account when building the decoder, add them here.

Your compiler setup is ready to be used now. Test it by running CMake with -DCMAKE_TOOLCHAIN_FILE=path\to\Qt\QtMCUs\1.5.0\cmake\Qul\toolchain\<YOUR_COMPILER>.cmake.

Available under certain Qt licenses.
Find out more.