<div dir="ltr">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. <br><div><br></div><div>Am I missing something, or is there a way to somehow attach the necessary external libraries to the object library as well?</div><div><br></div><div>Thanks,</div><div>--Jack</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 11:14 AM, Bill Hoffman <span dir="ltr"><<a href="mailto:bill.hoffman@kitware.com" target="_blank">bill.hoffman@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 11/17/2015 10:37 AM, Jack Stalnaker wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm trying to figure out the best way to handle something that was a<br>
convenience lib under autotools. I realize that there's a FAQ entry here:<br>
<br>
<a href="https://cmake.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F" rel="noreferrer" target="_blank">https://cmake.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F</a><br>
<br>
But its terse 2 paragraphs don't say how to actually do what it<br>
suggests. My problem is this. I have this source tree:<br>
<br>
lib<br>
|--foo.c<br>
|--foo.h<br>
|--bar.c<br>
|--bar.h<br>
|--baz.c<br>
src<br>
|--goo.c<br>
<br>
In lib, I need to somehow collectively refer to foo and bar. Okay, so I<br>
can create a variable:<br>
<br>
set(foobarSRCS foo.c bar.c)<br>
set(foobarLIBS ${externalLibFound})<br>
<br>
which is what the FAQ entry seems to suggest. However, this variable is<br>
not visible to goo.c. Okay, so as an alternative, I can do this:<br>
<br>
set(foobarSRCS foo.c bar.c PARENT_SCOPE), etc.<br>
<br>
but now the variable is not visible to baz.c, which also must include<br>
the srcs to create a module library called _baz! I can of course do<br>
something like this:<br>
<br>
set(foobarSRCSLOC foo.c bar.c)<br>
set(foobarSRCS ${foobarSRCSLOC} PARENT_SCOPE)<br>
<br>
but this feels dirty and repetitive.<br>
<br>
I also realize that I can just create the variables in src, but that<br>
kind of defeats the entire purpose of walling of the common libs and<br>
their dependencies in the first place.<br>
<br>
Is this the right way to work, or am I missing something simple?<br>
</blockquote></div></div>
There is a new feature to do that:<br>
<br>
<a href="https://cmake.org/Wiki/CMake/Tutorials/Object_Library" rel="noreferrer" target="_blank">https://cmake.org/Wiki/CMake/Tutorials/Object_Library</a><br>
<br>
-- <br>
Bill Hoffman<br>
Kitware, Inc.<br>
28 Corporate Drive<br>
Clifton Park, NY 12065<br>
<a href="mailto:bill.hoffman@kitware.com" target="_blank">bill.hoffman@kitware.com</a><br>
<a href="http://www.kitware.com" rel="noreferrer" target="_blank">http://www.kitware.com</a><br>
<a href="tel:518%20881-4905" value="+15188814905" target="_blank">518 881-4905</a> (Direct)<br>
<a href="tel:518%20371-3971%20x105" value="+15183713971" target="_blank">518 371-3971 x105</a><br>
Fax <a href="tel:%28518%29%20371-4573" value="+15183714573" target="_blank">(518) 371-4573</a><br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>