Skip to main content
Associate II
May 22, 2026
Question

CMakeLists.txt should use file(GLOB_RECURSE) instead of manually listing each file

  • May 22, 2026
  • 1 reply
  • 69 views
When generating a CMake-based STM32 project, STM32CubeMX currently lists every single .c source file manually in CMakeLists.txt.
 
This brings major inconvenience for users:
  • When adding user drivers (e.g., sensor, flash, display, or custom modules), users must manually edit CMakeLists.txt and add each new .c file path.
  • If the user adds many source files, this process is error-prone and inefficient.
  • It does not match modern CMake project practices and reduces project maintainability.
 
Suggestion:

Please use file(GLOB_RECURSE ...) to automatically include source files from standard directories such as:
  • Core/Inc/*.h
  • Core/Src/*.c

1 reply

Ghofrane GSOURI
Technical Moderator
May 22, 2026

Hello @ianzone 

First let me thank you for posting.

Your change request has been escalated to the development team and is being tracked under internal ticket ID #0062844 for further investigation and feasibility assessment.

THX

Ghofrane

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.