Additional source files in VisualCode project are not compiled

I tried to add some additional C++ files to my VisualCode project but it seems that they are not recognized by the buildsystem. There are linker errors about unknown references. When I put the code into the main.cpp files everything works.
After some investigation I assume the problem in the ninja configuration where only the main.cpp is mentioned.

Hi Michael!

If you want to use another .cpp file, you have to change CMakeLists.txt. For example i have two .cpp file named main.cpp and MyNewCppFile.cpp. Normaly in CMakeLists we can find line:

add_hexecutable(myproject main.cpp)

To contain MyNewCppFile.cpp this line should look like this:

add_hexecutable(myproject main.cpp MyNewCppFile.cpp)

Now everything should work.

Regards,
Hubert.

That was the trick.
Thank you!