<div dir="ltr">Hello.<br><br>I looked at this : <a href="https://cmake.org/Wiki/CMake/Tutorials/Object_Library">https://cmake.org/Wiki/CMake/Tutorials/Object_Library</a>,<br>and it suggests that I can use target_link_library() to combine static<br>libraries together. But I'm utterly failing at it.<br><br>Simple:<br>add_library(mylib STATIC ${lib_source})<br>target_link_libraries(mylib /path/to/libcool.a)<br><br>Doesn't work (libcool.a is not appended into mylib.a). If I want to link<br>against mylib (inside same cmake), then the libcool.a is added, however, <br>into the linkage of the executable that uses mylib.<br><br><br>I've tried making it more complicated by separating objects into an object<br>library, and then combining that object library and the external .a together<br>but it also doesn't do much:<br><br>add_library(mylib-obj OBJECT ${lib_source})<br>add_library(mylib STATIC $<TARGET_OBJECTS:mylib-obj> /path/to/libcool.a)<br><br>or<br><br>add_library(mylib-obj OBJECT ${lib_source})<br>add_library(mylib STATIC $<TARGET_OBJECTS:mylib-obj>)<br>target_link_libraries(mylib /path/to/libcool.a)<br><br>In all cases, cmake schedules ar on the object files, and ranlib on the<br>result.<br><br>Also, it seems it's not possible to create an empty library and add<br>other libraries as dependencies, which, in case of static libraries,<br>would make sense...<br><br>So, is is possible to, using cmake (and not do manual ar manipulations),<br>to create a static library containing objects from another static library,<br>external to the project?<br><br>Thank you!</div>