cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a library to a cmake project generated by STM32CubeMX

grzegorz
Associate III

I used STM32CubeMX to create cmake project for STM32F411CEUx. In the cmake\stm32cubemx directory there is a CMakeLists.txt file which defines a library called "stm32cubemx". This library contains all the code. Why STM32CubeMX uses such approach to project structure? Why treat all code as a library?

I have problem with extending such project. There is a simple library I created for earlier project: a directory containing CMakeLists.txt and library source files. How can I add this lib to my project? In the past I used to insert the add_subdirectory(mylib) directive to the main CMakeLists.txt file but it doesn't work here. My lib is ignored and lib's include directories are not seen in main.c. I can add the directive inside cmake\stm32cubemx\CMakeLists.txt but then I get an error informing that my lib dir is not a subdirectory of cmake\stm32cubemx.

I can add my lib files next to Drivers, Core, and Middleware and add their paths to cmake\stm32cubemx\CMakeLists.txt, but then my lib is no longer a lib, it's just all the files merged together, without separate CMakeLists.txt for the lib. It looks like the stm32cubemx lib is a closed item, which can't reference external CMakeLists.txt.

0 REPLIES 0