cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX CMake generated project will not load in VSC

dvescovi
Senior

I found if you generate a CMake project with STM32CubeMX and then try to open it Visual Studio Code w/extensions installed it does not always open and Ninja crashes.

I found if Cmake was previously installed ... as I assume most cross platforms developer probably have already done the STM32 Ninja has start up issues.

I always get things like:

[proc] Executing command: C:\ST\STM32CubeCLT_1.18.0\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe -v
[proc] Executing command: cube-cmake -S C:/GitHub/dv/Rcn600/stm32H563 -B c:/GitHub/dv/Rcn600/stm32H563/build -G Ninja
[proc] The command: cube-cmake -S C:/GitHub/dv/Rcn600/stm32H563 -B c:/GitHub/dv/Rcn600/stm32H563/build -G Ninja exited with code: 1
[extension] Using kits, skip selecting configure preset

 The kit scanner always seems to choke.

I did find a fix by placing following line in the .vscode/settings file:

 

 

 

 

 

4 REPLIES 4
Cartu38 OpenDev
Lead III

@dvescovi 
Not able to see in your message what update done as part of .vscode/settings file ... could you share it back ?

Such said looking at toolchain path used I can conclude your setup is not ok. Toolchain is expected to be part of STM32Cube bundles repository. You're pointing on CLT stuff which is deprecated with this new extension set.

Cartu38OpenDev_0-1771058674388.png

Not an issue to have locally your own cmake, ninja, CLT install it's well managed BUT you have to get proper setup to get stuff working with expected assets. Have got a chance to perform a project setup ? See: https://community.st.com/t5/stm32cubeide-for-visual-studio/how-to-reopen-the-initial-cubemx-popup-in-vs-code/td-p/877737.
This process is adding right pointers to expected utilities like ninja, toolchain & co.


 

the "cmake.useCMakePresets": "always",     made all the difference

{
"cmake.cmakePath": "cube-cmake",
"cmake.configureArgs": [
"-DCMAKE_COMMAND=cube-cmake"
],
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.useCMakePresets": "always",
"stm32cube-ide-clangd.path": "cube",
"stm32cube-ide-clangd.arguments": [
"starm-clangd",
"--query-driver=${env:CUBE_BUNDLE_PATH}/st-arm-clang/19.1.6+st.10/bin/starm-clang.exe",
"--query-driver=${env:CUBE_BUNDLE_PATH}/st-arm-clang/19.1.6+st.10/bin/starm-clang++.exe"
]
}

 

Oh and by the way the documentation about using CubeMX for project creation and then loading VSC is missing a few steps ... like pressing the "CODE GENERATION" button!

Interesting point @dvescovi.

 

I'm wondering if cmake.useCMakePresets should be set to always by default in the extensions for managed projects.

However, since our STM32CubeMX projects should contain a CMakePresets.json file in the project root directory, the CMake Tools documentation makes me doubt that we fully understand this issue:

JulienD_0-1771251951696.png

(see here)

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.