I have been curious about the difference between including a file in another source file with #include filename.h
and "adding" a source to a C++ project.
In Visual Studio, adding a source file to a project is done by right clicking and choosing "add existing source to project".
We don't need to do that to a file that is in the "additional directories" path and included using #include
.
However, sometimes .cpp files which are not #included
need to be added to the project.
So:
When is it that a .cpp file needs to be added to my project?
Also, W/R/T to CMAKE:
When I specify include_directories
and point it to the path where I my files to be included are, and those files are referenced in the source, why do I also have to add every header with add_exectuable
?
In other words, those files are included with #include
and CMAKE knows where to look for them, so what does setting add_executable
do?