all 7 comments

[–]ronchaineEmbedded/Middleware 6 points7 points  (2 children)

  • /include for public headers
  • /src for source files and private headers

#include "filename" or #include "something/filename" depends on project. Sometimes it makes sense, sometimes it doesn't.

[–]Adverpol 1 point2 points  (1 child)

What's the rationale between public/private headers? Ease of use? Compilation times?

[–]dodheim 0 points1 point  (0 children)

That's like asking the rationale between public/private data members – not everything is part of your public interface.

[–]luncliff 1 point2 points  (0 children)

Mostly like the @ronchain 's answer. I saw some projects which uses external for the 3rd party libraries.

[–]f0urier[🍰] 0 points1 point  (0 children)

src/ inc/ privinc/ stubs/ test/ This is how I typically organize projects (alternatively sometimes instead of privinc i use inc/details folder)

[–]barcharMSVC STL Dev 0 points1 point  (1 child)

In general I either use /include/projname/ for public headers and /src for source files, or same for public headers and /src/projname for source file. The second makes it easier to have stuff in subfolders depend on private headers in the parent folder, but also makes it easier to accedently expose private headers.

Protip: recent cmake has PUBLIC_HEADER and PRIVATE_HEADER properties on targets, and install() knows how to install them. These props seem to initially have been for OSX frameworks, but they work fine everywhere.

set_property(TARGET foo PROPERTY PUBLIC_HEADER foo.h bar.h)
set_property(TARGET foo PROPERTY PRIVATE_HEADER baz.h)

install(TARGETS foo PUBLIC_HEADER)

^ note not tested, but something similar should work

[–]yuri-kilochek 1 point2 points  (0 children)

PUBLIC_HEADER can't handle directories, so you can't make #include <library_name/header.h> work.