Building libraries on a library-by-library basis

I am trying to figure out, how do I include one single library into the compilation of my project - while ignoring others.

I have two projects that share a git submodule and inside the git submodule there are two libraries

├─ .gitlab-ci.yml
├─ docs/
├─ lib/
│  ├─ LEDController/
│  │  ├─ LEDController.cpp
│  │  ├─ LEDController.h
│  ├─ LockGuard/
│  │  ├─ LockGuard.cpp
│  │  ├─ LockGuard.h
│  ├─ mylibc/
│  │  ├─ include
│  │  │  ├─ mystring.h
│  │  ├─ string
│  │  │  ├─ mystrncpy.cpp
├─ lib_for_unit_testing/
│  ├─ LEDController/
│  │  ├─ LEDController.cpp
│  │  ├─ LEDController.h

Basically, I want to include everything in library_submodule/lib except for LEDController since it has some dependencies that I cannot include. I instead want to use the LEDController in library_submodule/lib_for_unit_testing since it’s minimal.

How do I include just the ones I want? I have tried -I./library_submodule/lib/LockGuard but it only includes the header and I get a linker error. How do I get Lockguard.cpp to be included in compilation?

Unfortunately, the folder structure is a bit fixed and, I can’t use lib_ignore = LEDController because, in this case, I still need LEDController but just from a different path.


Is there anyone that can help?

I basically just want to use the lib_extra_dirs option but only adding the library itself, not a folder of libraries. So a bit like in cmake where you choose exactly what you want to add in


lib_deps accepts a symlink://. See docs and docs.

Great, thanks for that. I’ll give it a go