[CMake] object file target

Hendrik Sattler post at hendrik-sattler.de
Mon Jul 30 16:58:21 EDT 2007


Am Montag 30 Juli 2007 22:44 schrieb Juan Sanchez:
> It's pretty messy the Makefile I am trying to convert.  It is trying to
> do something like this:
> g++ -shared obj1.o obj2.o obj3.o staticarchivex.a staticarchivey.a -o
> sharedlibrary.so
>
> The static archives are compiled with "-fPIC" so dynamic relocation is
> not a problem.
>
> Unfortunately, this only appears to work when at least one object is
> listed first, so I need at least one object.
>
> Too make a long story short.  It would be nice to just have optimal
> dependency checking for the object files so they aren't always being
> recompiled.  If you know how to extract the archives into a shared
> library in a better way, I'd appreciate that info too.

Did you try to make it straight-forward without any tweaking around?:
add_library (staticarchivex STATIC ...)
add_library (staticarchivey STATIC ...)
add_library (sharedlibrary SHARED obj1.c obj2.c obj3.c)
target_link_libraries(sharedlibrary staticarchivex staticarchivey)

Any reason why that shouldn't work?

HS


More information about the CMake mailing list