[CMake] Combining two static libraries into one
Kyle Edwards
kyle.edwards at kitware.com
Tue Jul 2 11:18:51 EDT 2019
On Tue, 2019-07-02 at 20:44 +0530, vinay kumar Kotegowder wrote:
> Hi Everyone,
>
> I have a requirement on combining two static library into one.
> Can anyone tell me how can I achieve this?
>
> Regards,
> Vinay
If you just want to make a library such that linking against that
library links against your two static libraries, you could use an
interface library. Example:
add_library(lib1 STATIC lib1.c)
add_library(lib2 STATIC lib2.c)
add_library(lib1_2 INTERFACE)
target_link_libraries(lib1_2 INTERFACE lib1 lib2)
Note that with this strategy, lib1 and lib2 will still exist as
separate files, but linking against lib1_2 will link against both of
these libraries.
Kyle
More information about the CMake
mailing list