cancel
Showing results for 
Search instead for 
Did you mean: 

How to build STM32CubeIDE project using CMake?

HTD
Senior III

I have a `cmake` directory in my project. It contains 2 generated files: `gcc-arm-none-eabi.cmake` and `st-project.cmake`. I think they were generated with the new Visual Studio CMake support for STM32CubeIDE feature, but I'm not sure.

I tried to enter the `build` directory, that is on the same level as `cmake` directory.

Then I tried: `cmake --fresh --toolchain=../cmake/gcc-arm-none-eabi.cmake ..`

The build fails when reaching the line of `st-project.cmake` that contains "virtual:/virtual" entry.

Also, when I try to build the program using STM32CubeIDE - it fails at linking telling me I have multiple definitions of main. When I clear all the make output it works properly.

What am I doing wrong? BTW, how are those make files created?

I have another problem - let's say I added or removed some files in my project. Do I really need to manually change multiple configuration files to apply the change? Or is there something a main source of the directory structure that would reflect the changes to other files? I made my project editable with VSCode, just by manually copying all include and toolchain directories into its settings. Code intelligence works fine, however - when I add a directory, I need to add it both to STM32CubeIDE, and to VSCode settings. And now - probably to the cmake file. I'm guessing the cmake can be used in VSCode somehow to make it all automatic, but I don't know how to achieve it, or if the generated cmake files are even usable by VSCode CMake Tools plugin. What I try to achieve is also building and debugging support for VSCode. I already figured out I can compile and build the project manually just by invoking the toolchains compiler and linker. But why do it by hand, when I already have cmake files generated?

2 REPLIES 2
kfruchtnis
Associate II

I have a similar issue. Existing project full of CMakeLists.txt files, which I would STM32CubeIDE to import and open as a project.
Any ideas where to start?

Please search in this forum, there were recently some interesting posts.