3

I have an external project that builds me a few static libraries. What I want to do is to link them into single shared library with my cmake.

The first thing I need to do is to add_library:

add_library(my_shared_lib SHARED ?????)

as I don't have any source files there (only static libraries), there is nothing to specify after SHARED. (I tried to put my static libs, but it won't take it).

So my question is what do I need to put instead of the question marks?

I also assume that if I target_link_libraries after that, then I'll get what I want.

Has anybody done this?

Dmitry
  • 2,837
  • 1
  • 30
  • 48
  • 1
    This is a duplicate. Here is your answer. http://stackoverflow.com/questions/11429055/cmake-how-create-a-single-shared-library-from-all-static-libraries-of-subprojec – RobertJMaynard Nov 05 '12 at 15:31
  • 1
    It's not exactly the same. The difference is that in my case those static libraries are not compiled by cmake and I can not do add_library(.. OBJECT) for them. – Dmitry Nov 05 '12 at 20:07
  • 1
    So far I've just created a dummy C file to put it in the source list and also had to put option -Wl,-whole-archive. Got the shared library as I wanted, but it also affected other parts of the build. Trying to figure out what's wrong – Dmitry Nov 05 '12 at 20:09

0 Answers0