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.
Adding <YOUR_COMPILER>.cmake
toolchain file 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:
Variable | Description |
---|---|
CMAKE_SYSTEM_NAME | The operating system CMake is building for. This must be set to Generic . |
CMAKE_SYSTEM_PROCESSOR | The processor CMake is building for. For example, if your target CPU is ARM CPU, set this to arm . |
COMPILER_FOLDER_NAME | Tells 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_OPTION | This specified the commandline option that the linker required to include a linker script. For GNU toolchains this is -T , while IAR used --config . |
CMAKE_C_COMPILER | Path to the C compiler. |
CMAKE_CXX_COMPILER | Path to the C++ compiler. |
CMAKE_ASM_COMPILER | Path to the assembly compiler. This is not needed if you do not have assembly files in you platform. |
CMAKE_AR | Path to the toolchain's archiver. |
CMAKE_CXX_FLAGS_INIT | C++ compiler flags that are used in every configuration. |
CMAKE_C_FLAGS_INIT | C compiler flags that are used in every configuration. |
CMAKE_C_FLAGS_DEBUG | C compiler flags that are used in debug configuration in addition to the flags used in CMAKE_C_FLAGS_INIT . |
CMAKE_CXX_FLAGS_DEBUG | C++ compiler flags that are used in debug configuration in addition to the flags used in CMAKE_CXX_FLAGS_INIT . |
CMAKE_EXE_LINKER_FLAGS_INIT | Linker 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>
(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 from the general project setup.
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 asWall
andWerror
. 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 forPlatform
here.src\CMakeLists.txt
is used to buildCore
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/2.9.0/cmake/Qul/toolchain/<YOUR_COMPILER>.cmake
Available under certain Qt licenses.
Find out more.