For small programs with only few source files there is no need to setup a directory structure. In case of medium and large project a proper directory structure is necessary to control project files, it also provides the means for dividing the project into smaller modules, which can be compiled separately and independent from other modules. Also running unit tests again after something goes wrong takes less time.
I am not creating big projects, but lets start small. Below is a simple directory structure:
Project │ ├───doc ├───inc ├───lib ├───src ├───CMakeLists.txt └───README
I added two files (README and CMakeLists.txt). The README file contains a brief description what is the project and what it does, contains installation instruction and information about the author. The CMakeLists.txt is the cmake build automation tool configuration script, which contains all the rules to build, package and install the software.
The inc folder holds all the header files (C/C++ header files), the src contains the source code. I also added the lib folder, because sometimes there is a need to include a library, which isn’t in the system.