C++ – Big project with many external libraries – source code organisation

ccode-organizationlibrariessource code

I was wondering what is the best way to organize my source code. I was researching on SO and found https://stackoverflow.com/a/1398594/137261 but this source code layout is library specific and doesn't cover my situation.

My situation:

  • 10 own modules (100k lines of code)
  • 15 external libraries (e.g. boost, sqlite, zlib, etc.)
  • 2 critical modules have to be available for selected developers only (maybe separate git repos ?)
  • project is multiplatform (Linux and Windows)
  • Git as version control system
  • cmake used to build project

Question:

  • does it make sense to incorporate all libraries into my project e.g. in _3rd_party_libs_ folder ?
  • how to handle lib include paths in my modules (environmental variable, relative paths, git submodules, etc. ) ?
  • should I always build external libs from source or just use their binaries ?

Best Answer

does it make sense to incorporate all libraries into my project e.g. in _3rd_party_libs_ folder ?

Do whatever you want, but keep it consistent. I do note that you've listed examples such as boost/sqlite; these should be standard in your dev environments and not included in your project, unless you depend on say some funny version of boost.

how to handle lib include paths in my modules (environmental variable, relative paths, git submodules, etc. ) ?

This is what your build system - CMake - is for. Your source code just has #include <third_party_lib.h> without worrying about where they are located.

should I always build external libs from source or just used their binaries ?

Prefer binaries by default, unless you have a good reason to build from source every time.

Related Topic