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?