The example you provided shows how you can combine raw object files into a single library. As far as I am aware CMake doesn't offer a nice cross platform API for extracting the object files from a static library and adding them to a new static library.
On Thu, Jun 15, 2017 at 10:19 PM, Pawel Veselov <[email protected]> wrote: > Hello. > > I looked at this : https://cmake.org/Wiki/CMake/Tutorials/Object_Library, > and it suggests that I can use target_link_library() to combine static > libraries together. But I'm utterly failing at it. > > Simple: > add_library(mylib STATIC ${lib_source}) > target_link_libraries(mylib /path/to/libcool.a) > > Doesn't work (libcool.a is not appended into mylib.a). If I want to link > against mylib (inside same cmake), then the libcool.a is added, however, > into the linkage of the executable that uses mylib. > > > I've tried making it more complicated by separating objects into an object > library, and then combining that object library and the external .a together > but it also doesn't do much: > > add_library(mylib-obj OBJECT ${lib_source}) > add_library(mylib STATIC $<TARGET_OBJECTS:mylib-obj> /path/to/libcool.a) > > or > > add_library(mylib-obj OBJECT ${lib_source}) > add_library(mylib STATIC $<TARGET_OBJECTS:mylib-obj>) > target_link_libraries(mylib /path/to/libcool.a) > > In all cases, cmake schedules ar on the object files, and ranlib on the > result. > > Also, it seems it's not possible to create an empty library and add > other libraries as dependencies, which, in case of static libraries, > would make sense... > > So, is is possible to, using cmake (and not do manual ar manipulations), > to create a static library containing objects from another static library, > external to the project? > > Thank you! > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
