r/cpp • u/TheRavagerSw • Sep 20 '26
Self Contained Source Groups are amazing
I basically adopted this idea from Abseil (https://abseil.io/) and from this CppCon talk: https://youtu.be/re4Oy1IVj-s?si=3bwtKqOyMAX6WSAs.
I structure each source group in my projects like this:
src_grp/
├── iface/
│ └── smth.cppm
├── impl/
│ └── smth.cpp
├── inc_pub/
│ └── pub.hpp
├── inc_priv/
│ ├── priv.hpp
│ └── maybe.inc
├── test/
│ └── test.cpp
├── bench/
│ └── bench.cpp
└── docs/
├── some.md
└── doxygen.in
I strongly recommend this approach over older project-wide conventions such as having a single global test/ or bench/ directory etc.
0
Upvotes
View all comments
Show parent comment
3
u/gracicot Sep 21 '26
I must admit I never tried large scale. With the normal pitchfork layout I've deployed about 20k lines projects, and with the modularized layout I've deployed about 120k lines projects. I've never attempted a larger project, but if I had to create million lines project I would probably take the modularized pitchfork separated by packages, and use a monorepo to combine all the packages.
Annoying? Maybe, but I far prefer a definite structure to just an ad-hoc tree with hundreds of files in them.