Skip to main content
Associate
Apr 26, 2024 2:54 PM UTC
Solved

CMake project generation with CubeMX + CubeAI fail

Hello,

I use STM32CubeMX V6.11.1 with cmake version 3.28.1 (the one embedded in STM32CubeCLT_1.15.1) to generate a project for STM32F746G Discovery kit.

When trying the new cmake project generation feature in conjunction with CubeAI, the generated project is not building.

I get the error:

```
[build] Starting build
[build] Build finished with exit code -1
[cmake] -- Configuring done (1.8s)
[cmake] Build type: Debug
[cmake] CMake Error at CMakeLists.txt:64 (target_link_libraries):
[cmake] Cannot find source file:
[cmake]
[cmake] C:/projects/st_trials/X-CUBE-AI/App/network.c
[cmake]
[cmake]
[cmake] CMake Error at CMakeLists.txt:38 (add_executable):
[cmake] No SOURCES given to target: ai_app
[cmake]
[cmake]
[cmake] CMake Generate step failed. Build files cannot be regenerated correctly.
```
This issue is due to the file `cmake\stm32cubemx\CMakeLists.txt` being incorrectly generated and containing two issues:
 
The first one is that all over the file some path are one level too high, for example:
```
target_include_directories(stm32cubemx INTERFACE
    ../../X-CUBE-AI/App
    ../../X-CUBE-AI
    ../../Core/Inc
    ../../../Middlewares/ST/AI/Inc #<---incorrect path
    ../../../X-CUBE-AI/App #<---incorrect path
    ../../Drivers/STM32F7xx_HAL_Driver/Inc
    ../../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy
    ../../Drivers/CMSIS/Device/ST/STM32F7xx/Include
    ../../Drivers/CMSIS/Include
)
```
 
The second one is that for some reason in `target_include_directories` the main includes are omitted (e.g. `
    ../../Core/Inc`)
 
Once corrected, the project builds but everytime the project is regenerated, the file `cmake\stm32cubemx\CMakeLists.txt` is overwritten and the correction have to be redone. Is there a way to have the project correctly building after generation?
 
Thanks in advance for the response
This topic has been closed for replies.
STTwo-32
STTwo-32Best answer
ST Technical Moderator
Feb 8, 2025 3:05 PM UTC

Hello @jjaccard 

I’m not able to reproduce this behavior with the STM32CubeMX V6.13.0. If you still have the same issue, please tel me to check this again for you @Remyhx , please create a new post on the wireless forum since it is a wireless product related your issue with a description of all your case details and with a .ioc file that reproduce your behavior on the CubeMX V6.13.0.

Best Regards.

STTwo-32

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.

6 replies

STTwo-32
ST Technical Moderator
Apr 26, 2024 7:35 PM UTC

Hello @jjaccard and welcome to the ST Community :smiling_face_with_smiling_eyes:.

Can you share your .ioc file so we can try to reproduce (with a description on how you did it if possible).

Best Regards.

STTwo-32 

 

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.
jjaccardAuthor
Associate
Apr 29, 2024 8:55 AM UTC

Hello,

Thanks for the welcome : )

Sure, you can find linked the .ioc file. As mentionned above, I created a project with STM32CubeMX V6.11.1 for STM32F746G Discovery kit (all default periph.). I then added X-CUBE-AI V9.0.0 with the application template and added a simple dense .tflite model. Finally I generated the code for cmake toolchain.

Then I followed your video to open and import the cmake project in vscode: https://www.youtube.com/watch?v=DDVdq47Dd94

And when I try to build, the issue mentioned in my original post arise. As mentioned above, I can fix it but every time I want to change something in CubeMx and regenerate the code I have to re-fix the build system (when I update the .tflite model for example, which happens quite often).

Thanks in advance for the help.

Jérémie

STTwo-32
STTwo-32Best answer
ST Technical Moderator
Feb 8, 2025 3:05 PM UTC

Hello @jjaccard 

I’m not able to reproduce this behavior with the STM32CubeMX V6.13.0. If you still have the same issue, please tel me to check this again for you @Remyhx , please create a new post on the wireless forum since it is a wireless product related your issue with a description of all your case details and with a .ioc file that reproduce your behavior on the CubeMX V6.13.0.

Best Regards.

STTwo-32

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.
Remyhx
Associate III
Feb 10, 2025 5:19 PM UTC

Also 6.13.0, migrated from 6.12. Couple of times gave me the error, but somehow it vanished. Thx for the reply.

jjaccardAuthor
Associate
Jun 3, 2024 3:48 PM UTC

Hello,

 

Any news on this issue?

 

Thanks

Remyhx
Associate III
Feb 8, 2025 2:54 PM UTC

Same kind of mistake here: STM32WB with first ble included, later excluded. Had to remove tinylpm.c from cmake/stm32cubemx/cmakelists.txt. Every time I regenerate the project it has to manually be removed.

I see no follow up from STM.