Showing results for 
Search instead for 
Did you mean: 

BUG: STM32CubeMX should not create an INTERFACE library when CMake selected



After some work with STM32CubeMX CMake generation and discussions with good CMake user, I really think that, when generating a projet with STM32CubeMX, it should not be an INTERFACE library (or at least not only that)

As a CMake user said to me, the purpose of INTERFACE library is the following:

When a target represents some collection of requirements that doesn’t involve an actual library file. For example, a collection of flags or includes.

The main problems I have when using the current CMake generation:

  • I'm linking several libs to the project. They have to be linked to the stm32cubemx lib to have µC and #define defined. Every lib compilation involve a stm32cubemx lib compilation.
  • I want to change some compilation flag in my lib. For example, level up somes warnings to errors such as implicit conversion or unused parameters. As the stm32cubemx is an interface, when it is compiled, it "takes" the compilation flag of the linking lib. As a result, errors compilation rise because there are warning in stm32cubemx lib

For me, STM32CubeMX CMake generated project should be more like that:

  • A main CMakeLists.txt creating an executable
    • This executable should add the core sources (main.c, gpio.c, ...)
    • As now, it should allow to link libs, add compile_definition...
  • A CMakeLists.txt creating a non INTERFACE library, containing all the Drivers/STM32...._HAL_Driver/Src
  • A CMakeLists.txt creating an INTERFACE library containing the #define, compilation flags, µC informations. It could be included in the previous file.

Integrating CMake project generation in STM32CubeMX is really a good idea. For me it is really a major improvement of the Cube suite. But for now it is not usable without some modifications.

I would be really happy to talk of the subject with ST employees and to see (some of) those modifications integrated in the next STM32CubeMX.





ST Employee

Hello @ANauz.1 ,

Thank you for having reported the point.

Your request is escalated internally to our team to be analyzed through ticket number: 184662.

We will be back to you as soon as possible.

(PS: ticket number 184662 is an internal tracking number and is not accessible outside of ST)

When your question is answered, please close this topic by clicking "Accept as Solution".
Associate II

Same issue here! It's really frustrating, for now I've come up with this workaround, for everyone new to this issue/problem.