[CMake] actually using cmake alternative to convenience libraries

Bill Hoffman bill.hoffman at kitware.com
Fri Nov 20 14:23:56 EST 2015


On 11/17/2015 2:46 PM, Jack Stalnaker wrote:
> I read about those, but they don't seem to provide a way to add linked
> in libraries, so it didn't seem to add a lot over a list of sources. In
> autotools, you could bind your convenience lib with any dependencies via
> a LIBADD primary, and the added libs would automatically propagate to
> the final target. This of course works in cmake if I build a real
> library, but if I try to link a library (e.g. say the system math
> library) to the object library, cmake tells me it cannot do that for
> object libraries. In that case, it seems like I still need to create the
> foobarLIBRARIES variable to provide to target_link_libraries later.
>
> Am I missing something, or is there a way to somehow attach the
> necessary external libraries to the object library as well?
It is a feature that has not been implemented.  However, I would say 
that it does add something over lists of sources.  It avoids all the 
cache and parent scope in this thread.  Seems like it would still be 
more simple to use object libraries than to try and do it via lists of 
sources.

To add that feature would be some work, but is possible:
  https://cmake.org/Bug/view.php?id=14778
  https://cmake.org/Bug/view.php?id=14970

I still think the object libraries might work for you.

-Bill


More information about the CMake mailing list