I have a project that depends on 3 libraries A, B and C. A and B are git repositories that are based on CMake, and both depend on C and therefore include it as a submodule (but different versions from different repos). Thus, the structure of my project looks like this:
ext/
libA/
libC/ (submodule of libA repo)
...
libB/
libC/ (submodule of libB repo)
...
main.cpp
CMakeLists.txt
CMakeLists.txt looks like this:
add_subdirectory("ext/libA")
add_subdirectory("ext/libB")
add_executable(MyApp main.cpp)
target_include_directories(MyApp ...)
target_link_library(MyApp libA libB libC)
What is the best way to deal with this nested shared dependency? Ideally, I would use one version of libC for libA, libB and my project, but I don’t know that this is a non-intrusive way (i.e., without changing the cmake libA and libB files).
I really like the combination of submodules and CMake add_subdirectory, because it's simple and clean, but nested dependencies are complex.