Skip to main content
Associate
May 17, 2026
Solved

Add new C file to my STM32 project in VS Code

  • May 17, 2026
  • 1 reply
  • 147 views

If I add a new .c file to my project in core/src it does not get recognized and is not complled. How do I get it into the make list?

Thanks

Best answer by Julien D

Hi @fritz3917,

There is no managed build, so you must define your new source file manually, preferably by editing the top-level CMakeLists.txt file:

# Add sources to executable/library
target_sources(<PROJECT_NAME> PRIVATE
 # User defined sources
 core/src/newFile.c
)

 <PROJECT_NAME> to be replaced according to your project (see used value from the cmake files).

1 reply

Julien D
Julien DAnswer
ST Employee
May 18, 2026

Hi @fritz3917,

There is no managed build, so you must define your new source file manually, preferably by editing the top-level CMakeLists.txt file:

# Add sources to executable/library
target_sources(<PROJECT_NAME> PRIVATE
 # User defined sources
 core/src/newFile.c
)

 <PROJECT_NAME> to be replaced according to your project (see used value from the cmake files).

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.
fritz3917Author
Associate
May 18, 2026
Thanks, that worked.