diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a22987 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# NewProject +--- +A simple demonstration of how to include multiple cpp files in a single project, using cmake. + +There are three strategies: +1. direct declaration in the main, with the external source files identified in the cmakelist add_executables. +2. explicit inclusion (`#include mysource.cpp`). In this case, they should not be added to the cmakelist. +3. The "canonical" or "best practice" c++ approach: explicit inclusion of a header file (`#include mysource.h`) which declares all the classes and methods publicly accessible to main. Both the source and header must be added to cmakelist. + +Here is my main, with all three strategies implemented: + +![inclusions](img/inclusions.png) + +Here is the cmakelist: + +![](img/cmakelist.png) + +Note, that you'll have to specify your version of cmake in the `set`. + +You can build this with this command: + +```shell + cmake --build {your-project-path}/NewProject/cmake-build-debug --target NewProject -j 14 +``` + +And when you run the compiled binary, you should see: + +![the output](img/output.png) \ No newline at end of file diff --git a/img/cmakelist.png b/img/cmakelist.png new file mode 100644 index 0000000..d8a5f4a Binary files /dev/null and b/img/cmakelist.png differ diff --git a/img/inclusions.png b/img/inclusions.png new file mode 100644 index 0000000..3e481cb Binary files /dev/null and b/img/inclusions.png differ diff --git a/img/output.png b/img/output.png new file mode 100644 index 0000000..aab2948 Binary files /dev/null and b/img/output.png differ