I try to encapsulate in a module a set of c++ classes (.cpp and .h) that I share with some other projects.
The special convention of putting headers in a Public folder and source in a Private folder is really constraining in my case for a few reasons:
- The structure of classes put in a hierarchy of directories should be replicated in the Public folder.
- My other projects would have to inherit from that constraint which would break their standard coding guidelines.
- Having .h and .cpp together is rather standard and allows more logical #include “classname.h” convention.
- For each include I would always have to put a full path even if they would normally be in the same directory.
I tried already if I could:
- Put all the code in the Public folder but my understanding is that sources (.cpp) should stay in Private.
- Duplicate headers in Public and keeping them also next to source for the other projects (but that’s a bad practice and we should avoid code file duplication).
- Have headers in Public that are just including their Private header counter part. But this fails also when headers include other headers.
A possible solution could be that Public include files could still search in the Private include path, but I couldn’t find a way to get the module Build.cs to achieve that.
Is there no way to avoid putting headers in a separate Public folder so that my non UE projects wouldn’t inherit that constraint if I want to share the code without duplicating files? I wish I could just put one header in Public with a list of all headers to place public but then I get errors when those include refers to other includes.
Any solution would be welcome.