2026-02-03 1:24 AM
Hi!
I am working on creating a new build system for my for a software platform using CMake to help with management of different targets and toolchains. I have an .ioc file that is currently in use with the existing build system based on CubeIDE that contains all middleware (FreeRTOS, LwIP, TouchGFX) additions and configurations, so I am not changing anything.
I am trying to make the build as modular as possible so I am trying to link the stm32cubemx and touchgfx CMake targets directly. I am using build presets to manage configuration. Creating the build system works fine, but when I try to run the build I get compilation errors because the TouchGFX related files can't find the user constants defined in CubeMX for TouchGFX, as shown below:
This can be expected because these symbols are created in defines on main.h and the TouchGFX file being referred there does not include main.h. I could add it manually, but I'd like to try to get the system to work directly from autogeneration if possible. After investigating and getting some help from Copilot, it seems that TouchGFX expects these symbols to be provided differently. Apparently, these "User Constants" that are generated as defines in main.h should also appear in the CMakeLists.txt file for the stm32cubemx target under "MX_Defines_Syms".
The picture below shows the "User Constants" section on CubeMX:
And these symbols appear in the main.h file under Core/Inc:
But they are not generated in CMakeLists.txt for CubeMX, as it should (according to Copilot):
Is this expected behavior or is CubeMX failing to include those symbols in the CMake file? Is there anything I need to select on CubeMX for it to generate these on the CMake file? Maybe Copilot is hallucinating?
I'd like to know what you think is the best approach to build these two together using CMake.
I am using CubeMX v6.16.1 and TouchGFX Designer v4.26.0
Thank you in advance.
// Rene
2026-02-03 2:12 AM
Hello @ReneAlexandeR
Thank you for posting!
Which MCU are you using? or could you attach an IOC in order to investigate the issue?
BR, Souhaib
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2026-02-03 2:27 AM