<div class="gmail_quote">On Thu, Jan 29, 2009 at 11:38 PM, ankit jain <span dir="ltr">&lt;<a href="mailto:ankitguddu@gmail.com">ankitguddu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br>
<div class="gmail_quote">2009/1/29 Pau Garcia i Quiles <span dir="ltr">&lt;<a href="mailto:pgquiles@elpauer.org" target="_blank">pgquiles@elpauer.org</a>&gt;</span><div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
<div>
<div></div>
<div>On Thu, Jan 29, 2009 at 1:12 PM, ankit jain &lt;<a href="mailto:ankitguddu@gmail.com" target="_blank">ankitguddu@gmail.com</a>&gt; wrote:<br>&gt; hi all,<br>&gt;<br>&gt; Problem:<br>&gt;<br>&gt; libA : A/foo.cc<br>&gt; libB : B/bar.cc<br>

&gt; and a 3rd library:<br>&gt; libC : A/foo.cc B/bar.cc<br>&gt; ?<br>&gt;<br>&gt; here i build the libraries for A and B but not able to build lib for C .<br>&gt; Guide me to do that. What should be the content of cmakelist file of C to<br>

&gt; create lib C<br>&gt;<br>&gt; here A and B are sub folders of C<br><br></div></div>Do you ean you are trying this but it&#39;s not working?<br><br>ADD_LIBRARY (libA A/foo.cc )<br>ADD_LIBRARY (libB B/bar.cc )<br>ADD_LIBRARY (libC libA libB )<br>

<br>That fails because CMake does not support convenience libraries:<br><a href="http://www.cmake.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F</a><br>

<br>You need to do this:<br><br>ADD_LIBRARY (libA A/foo.cc )<br>ADD_LIBRARY (libB B/bar.cc )<br>ADD_LIBRARY (libC A/foo.cc B/bar.cc )<br><br>I. e. list the source files for libC<br><br>Is that what you want to do?<br><font color="#888888"></font></blockquote>


<div>&nbsp;</div>
</div><div>Dont you think so it will be too hectic if there are 10 folders inside folder C and each folder has around 10 C files each. then listing all will be really cumbersome. </div>
<div>What should be the alternative for it.</div></div></blockquote><div><br>Here&#39;s one idea, in A and B set a variable with all of the source files and add them to the PARENT_SCOPE.<br><br>set(A_SRCS a.cc)<br>set(A_SRCS ${A_SRCS} PARENT_SCOPE)<br>
add_library(A ${A_SRCS})<br><br>Then in the higher directory, use a foreach() loop to construct a proper relative path to each source file:<br><br>foreach(fname ${A_SRCS})<br>&nbsp;&nbsp;&nbsp; list(APPEND C_SRCS A/${fname})<br>endforeach()<br>
foreach(fname ${B_SRCS})<br>&nbsp;&nbsp;&nbsp; list(APPEND C_SRCS B/${fname})<br>endforeach()<br>add_library(both ${C_SRCS})<br><br></div></div>-- <br>Philip Lowman<br>