0

I am developing a CMake project depending on multiple third-party libraries, and these libraries may further depend on other third-party libraries. The dependencies are all built as static libraries. I use ExternalProject to download and compile the dependencies.

                  /=> lib4.a
       /=> lib2.a  => lib5.a
lib1.so 
       \=> lib3.a

When linking lib1 against lib2, the symbols from lib4 and lib5 are missing. My alternative is to manually import lib4 and lib5 into lib1 and link against them. But this will cause all the dependencies to be built twice. When there are many dependencies, manually handling this becomes very hard.

I am thinking if there is a way for lib2 to create a big library (lib2-ALL) that includes everything from lib2, lib4 and lib5. So lib1 only needs to link against lib2-ALL. However, I am not sure how to do this properly in CMake.

What is a proper way to manage such multi-level third-party library dependencies?

Harper
  • 1,794
  • 14
  • 31
  • If they're all CMake builds, then install everything in dependency order to a common prefix and set `CMAKE_PREFIX_PATH` appropriately for each project. Otherwise, try vcpkg, it's designed for this sort of thing. – Alex Reinking Jul 07 '21 at 08:38
  • Maybe post some CMakeList snippets so that we can better understand what you are trying to do. Are you perhaps working with shared libraries? Because static libraries should be easier to work with. – bremen_matt Jul 16 '21 at 08:15

0 Answers0