2020-12-18 10:20 AM
Since it took a tremendous amount of effort in getting CMake working within STM32CubeIDE, I'd thought I'd share a method of getting it done. I've only tested this working in Windows. Many an hour could have been saved if ST, in their infinite wisdom, did not disable the Toolchain tree entry in the project C/C++ properties!
Disclaimer: I'm not an experienced Eclipse user, so there is a very good chance that the steps below are not the correct way of doing things, and in future, ST might lock-down or hide more UI rendering these steps useless - you have been warned!
There are a huge number of steps required, so this is not for the fainthearted!
Prerequisite: You must have an existing CMake GNU Arm project up and running, if not, find out how set one up, or use CLion to create a CMake project from an existing STM32CubeMX .ioc.
For the steps, I'm using the following folder layout (adjust to fit your preferences):
Source (source code, folders, etc)
build
.. this where I set CMake to run the builds..
cmake
gnu-arm-stm32.cmake
...
CMakeLists.txt
Tools
STM32CubeIDE
MyProject (the skeleton project created in the below steps)
.cproject
.project
svd
STM32F446.svd
Matthew.
Solved! Go to Solution.
2020-12-18 10:20 AM
Requires: STM32CubeIDE 1.5.0+, CMake and Ninja-build installed
Install CMake plugins
Ensure global Indexer settings are correct
Create skeleton STM32 project
Switch toolchain builder to CMake
Switch indexer to use CMake providers
Add root source code folder containing CMakeLists.txt
Update Include and Source locations
Configure CMake settings
Build all configurations to generate all outputs (.elf)
Add debug launch entries
Matthew.
2020-12-18 10:20 AM
Requires: STM32CubeIDE 1.5.0+, CMake and Ninja-build installed
Install CMake plugins
Ensure global Indexer settings are correct
Create skeleton STM32 project
Switch toolchain builder to CMake
Switch indexer to use CMake providers
Add root source code folder containing CMakeLists.txt
Update Include and Source locations
Configure CMake settings
Build all configurations to generate all outputs (.elf)
Add debug launch entries
Matthew.
2020-12-18 10:33 AM
(optional) Add updated GNU Arm toolchain
(optional) Exclude build folder files from indexing (might speed up indexing?)
(optional) Add J-Link debug launch entry
I have noticed that sometimes the CMake settings do not get saved properly to the .cproject file, so I need to edit that file (xml) before sending it to source control.
If I get a free moment, I'll create a demo blinky project based on a Nucleo and post it here if there's any interest ;).
Matthew.
2020-12-21 11:33 PM
Hi @Community member ,
Thanks for this valuable contribution.
Don't hesitate to select your own reply as a Best Answer so that this topic will be closed and this will help other users find that answer faster.
-Amel
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.
2020-12-22 01:23 AM
Thanks @Amel NASRI - Done!
Matthew.
2021-05-27 11:27 AM
This is fantastic and worked perfectly for me to enable debugging with STM32CubeIDE using an existing CMake project and toolchain. I didn't have to modify any CMake stuff at all. Thanks so much!
2021-12-02 11:51 AM
Great guide thank you so much! Everything worked perfectly EXCEPT for run/debug configurations. When attempting to run, I get a pop-up window saying I have invalid project settings specifically unknown toolchain. Tried a few things but can't seem to get around this error. Any suggestions?
2021-12-02 12:05 PM
Hi @Community member , I've given up on using CMake with STM32CubeIDE as too many changes were made to the IDE to keep it working with CMake. It would make more sense if ST themselves supported CMake in their IDE instead of having their end-users hack a solution together due to their Eclipse customisations. Knowing ST, this will be put on a backlog and it would be a small miracle if it saw the light of day. Sorry I can't be of help anymore on this 'fix'.
2021-12-02 02:22 PM
No problem I completely understand. For anyone else stumbling on this thread, the workaround I found for run/debug configurations is creating another dummy STM32 project with nothing in it with run/debug configurations pointing to the main project's output location on disk. Not great as the run configurations can't force a compile of the selected configuration so you MUST build the required one yourself first from the main project.
2022-12-19 01:50 AM
Seems like the CMake integration stopped working at least with STM32CubeIDE 1.11.0. The last version I worked with was 1.9.0.
The first steps, to comment out the nature and then edit tool chains, there is no CMake builder available.
Can you point me in the direction where to look further?