Suppose I am developing the libfoo library, written in a compiled language, and am using CMake to configure its build. This library itself depends on another library, libvar. Thus, if someone else is building the MyApp application, which uses my library, they have to have link both against libfoo and libbar (e.g. specify both -lfoo
and -lbar
).
Suppose the MyApp developer also uses CMake. And they write:
find_package(foo REQUIRED)
with my exported CMakeLists configuration files in the CMake search path. Naturally, this will propagate the dependency on libvar and result in the appropriate linking.
Now, suppose the MyApp developer wants to produce a static binary. Can they easily achieve that, both w.r.t. libfoo and to libvar? If not, what do I, as the library developer, need to do in my library’s CMakeLists, to ensure that MyApp completes a proper configuration of a fully static build?