2024-06-21 05:08 AM - edited 2024-07-02 09:43 AM
I've been using the recently added CMake generation feature of cubemx, as of now it creates an INTERFACE library for both project related and drivers related sources, the problem is that those sources get propagated for every external library that needs stm32cube drivers.
One workaround is creating a STATIC wrapper library like this:
# Retrieve properties from the INTERFACE library generated by STM32CubeMX
get_target_property(STM32_SOURCES stm32cubemx INTERFACE_SOURCES)
get_target_property(STM32_INCLUDE_DIRS stm32cubemx INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(STM32_COMPILE_DEFINITIONS stm32cubemx INTERFACE_COMPILE_DEFINITIONS)
get_target_property(STM32_LINK_DIRECTORIES stm32cubemx INTERFACE_LINK_DIRECTORIES)
get_target_property(STM32_LINK_LIBRARIES stm32cubemx INTERFACE_LINK_LIBRARIES)
# Log the properties
message(STATUS "STM32_SOURCES: ${STM32_SOURCES}")
message(STATUS "STM32_INCLUDE_DIRS: ${STM32_INCLUDE_DIRS}")
message(STATUS "STM32_COMPILE_DEFINITIONS: ${STM32_COMPILE_DEFINITIONS}")
message(STATUS "STM32_LINK_DIRECTORIES: ${STM32_LINK_DIRECTORIES}")
message(STATUS "STM32_LINK_LIBRARIES: ${STM32_LINK_LIBRARIES}")
The problem is that the INTERFACE library must still be linked against the root project because there are some sources that need to be propagated to the project, but drivers don't need to be propagated.
This causes the compilation of stm32cubemx sources twice, and I believe it consumes more flash space because of cloned sources(doing this the normal way, sources would get recompiled every time a library needs the drivers), and it's pretty annoying.
Is this going to get fixed(by creating an INTERFACE library for project related and a STATIC library for driver related, for example)?
2024-07-05 09:11 AM
Hello @Tizio1234
First let me thank you for posting!
Your request is escalated internally for further investigation.
We will be back to you as soon as possible.
KR,
Souhaib
2024-09-17 11:21 PM
Ticket reference: 187558. Analysis done, but work is not yet planned. Awaiting planning confirmation...
Posted a more thorough reply in: https://community.st.com/t5/stm32cubemx-mcus/bug-stm32cubemx-should-not-create-an-interface-library-when/m-p/687533/thread-id/28454