[CMake] Adding one static library into another

Eric Nodwell enodwell at ucalgary.ca
Wed Apr 28 15:57:32 EDT 2010


Is there any way to have CMake make a new static library that includes the objects from another existing static library?

As an example (here a Linux-specific example) of doing this manually, suppose I have an existing library "libA.a", as well as an object file "B.o" that I have just compiled, and I want to combine the two of them into a single static library named "libB.a" .  By hand I could do this:

ar xv libA.a      # generates an A.o or something similar
ar rcs libB.a B.o A.o

Can this be done (in a cross-platform way) with CMake commands?

(Of course, if I have access to the source code for A, this is simple, but that may not always be the case.)

Thank you for any tips,
Eric



More information about the CMake mailing list