[CMake] creating an sdk wrapper and hiding implementation

Alexander Neundorf a.neundorf-work at gmx.net
Wed Jul 25 16:24:42 EDT 2012


On Wednesday 18 July 2012, Michael Toy wrote:
> we have a number of internally developed libraries which we use together.
> 
> i am creating an sdk which wraps all the internal libraries, and presents a
> single api to customers.
> 
> i have built a small test by hand, and it works like this
> % cc -c sdk_api.c
> % ln -r sdk_api.o libinternal1.a libinternal2.a -o sdk.o
> -exported_sybmols_list sdk_api_entry.txt % strip -x sdk.o
> % ar r libsdk.a sdk.o
> 
> this creates a libsdk.a which ONLY has the api entry points exposed to
> customers and hides all the globals from the internal libraries.
> 
> can't quite wrap my head how to express this in cmake's world of sources,
> libraries and targets.
> 
> best i can think of is a custom target, which then depends on the internal
> libraries ( which are built in the same project ), and then somehow get
> the path names to the internal libraries to construct the link line, only
> i can't even figure out how to do that.
> 
> anyone have a clue?  we have ended up have tons of system specific target
> construction rules, so i don't mind if i have to write the custom target
> differently for different target OSes.

So basically this combines several static libraries into one static library ?
This is not really/kind of supported by cmake.
Since 2.8.8 (I think) you can create OBJECT libraries: 
add_library(... OBJECT ...)
which are basically only a set of object files, but can be used later on to be 
linked against.
So you could build libinternal1.a and libinternal2.a as such OBJECT libs, and 
then create a library sdk which links against those two.
I haven't tested this myself, but maybe it works and kind of does what you 
want ?

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120725/3bb267f5/attachment.htm>


More information about the CMake mailing list