This is a short-version explaining key steps to build project with CMake in VSCode or directly in shell.
Long version: https://github.com/MaJerle/stm32-cube-cmake-vscode
For successful compilation:
- CMake and Ninja-build tools installed and available in environment path
- ARM None Eabi GCC toolchain installed and available in environment path - if you have installed STM32CubeIDE, you have GCC already installed there - find it in directory and add it to env path
To further download the built project to STM32 hardware:
- STM32CubeProgrammer tool needs to be installed with bin folder in environment path - to have access to STM32_Programmer_CLI command - if you have installed STM32CubeIDE, you have GCC already installed there - find it in directory and add it to env path
For debugging from inside VSCode
- ST GDB-Server tool needs to be installed with bin folder in environment path - you get it together with STM32CubeIDE package
- Open terminal window in folder where
CMakeLists.txt
for your project is located - Run
cmake --preset Debug
to generate build system for ninja usingDebug
preset, that comes with the defaultCMakePresets.json
file - Run
cmake --build --preset Debug
to actually invoke ninja-build and compile with GCC - Go to
build/Debug
folder - you will find your.elf
file there (only if build is a pass). This is default build directory forDebug
preset that comes with the project - Clean the project with
cmake --build --preset Debug --target clean