<div dir="ltr"><div class="gmail_default" style="font-family:'courier new',monospace">Thanks to all who have replied for your efforts in trying to help me.  My apologies for any lack of clarity in describing my problem.</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">With the various information and advice you provided, I have been able to get my CMake configuration working.</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">Thanks again!</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">..chris</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 26, 2014 at 3:30 PM, Stephen Kelly <span dir="ltr"><<a href="mailto:steveire@gmail.com" target="_blank">steveire@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>Chris Johnson wrote:<br>
<br>
> * I do not want to use the add_library(component1 OBJECT<br>
> ${component1_sources}) and add_library(toplevel<br>
> $<TARGET_OBJECTS:component1> ... ) syntax if it can be avoided.<br>
<br>
</span>Is the constraint that you want a top-level something like<br>
<br>
  # All components:<br>
  set(components component1 component2)<br>
<br>
  foreach(comp ${components})<br>
    add_subdirectory(${comp})<br>
  endforeach()<br>
<br>
  add_library(mylib dummy.c)<br>
  target_link_libraries(mylib ${components})<br>
<br>
  add_executable(other_target main.c)<br>
  target_link_libraries(other_target mylib)<br>
<br>
?<br>
<br>
While at the same time not caring what type the components libraries are<br>
(OBJECT/STATIC etc)?<br>
<br>
A solution for that is in CMake 3.1 by creating an INTERFACE library to hide<br>
the TARGET_OBJECTS expression:<br>
<br>
 add_library(component1_objs OBJECT c1.c)<br>
<br>
 add_library(component1 INTERFACE)<br>
 target_sources(component1 INTERFACE<br>
   $<TARGET_OBJECTS:component1_objs><br>
 )<br>
<br>
There is a bug however, but I just pushed a fix for it after trying to<br>
extend your test case to use it:<br>
<br>
 <a href="http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=672f1001" target="_blank">http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=672f1001</a><br>
<br>
An INTERFACE library also helps you avoid the dummy.c by not creating the<br>
intermediate archive at all, if that fits within what you're trying to<br>
achieve here:<br>
<br>
  add_library(mylib INTERFACE)<br>
  target_link_libraries(mylib INTERFACE ${components})<br>
<br>
In the future it may be possible to link to OBJECT libraries directly<br>
without the INTERFACE library:<br>
<br>
 <a href="http://public.kitware.com/Bug/view.php?id=14970" target="_blank">http://public.kitware.com/Bug/view.php?id=14970</a><br>
<br>
Another obvious solution, if it fits within what you're trying to achieve,<br>
is to avoid the OBJECT libraries instead:<br>
<br>
 add_library(component1 INTERFACE)<br>
 target_sources(component1 INTERFACE<br>
   ${CMAKE_CURRENT_SOURCE_DIR}/c1.c<br>
 )<br>
<br>
This means that all binary consumers will compile their own version of each<br>
file, which you probably want to avoid.<br>
<br>
Additionally, you do need to specify an absolute path or CMake issues a not-<br>
informative-enough error. A second bug found from this thread, but which I<br>
haven't yet addressed (but should get done for 3.1 too).<br>
<br>
Thanks,<br>
<br>
Steve.<br>
<div><div><br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" 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" 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" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" 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" 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" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div></div>