<div class="gmail_quote">On Tue, Dec 22, 2009 at 10:35 AM, Michael Wild <span dir="ltr">&lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
On 22. Dec, 2009, at 16:22 , David Cole wrote:<br>
&lt;snip&gt;<br>
<div class="im">&gt;&gt;<br>
&gt;&gt; That&#39;s exactly my point: if the dependent project is the calling project<br>
&gt;&gt; (i.e. the one that calls ExternalProject_Add), you have to use error-prone<br>
&gt;&gt; ADD_LIBRARY(&lt;name&gt; &lt;type&gt; IMPORTED) calls with according invocations of<br>
&gt;&gt; SET_TARGET_PROPERTIES(&lt;name&gt; PROPERTIES IMPORTED_LOCATION &lt;filepath&gt;). In<br>
&gt;&gt; the case of Boost this is probably very difficult to get right, because from<br>
&gt;&gt; what I hear, the library names change almost randomly with operating system,<br>
&gt;&gt; compilation flags and what not. So what ExternalProject.cmake is missing, is<br>
&gt;&gt; a mechanism of &quot;pulling&quot; the targets of the external project into the<br>
&gt;&gt; calling project.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; So first build boost and everything with a simple &quot;build my prerequisites&quot;<br>
&gt; project that builds/installs all your prereqs in a nice, reasonable fashion.<br>
&gt;<br>
&gt; Then your project can just find/include/import everything as your accustomed<br>
&gt; to without any fuss.<br>
<br>
</div>That is a workable solution for &quot;tech-savvy&quot; users, I&#39;m not so sure the average admin will appreciate it (remembering the heated and quite ridiculous discussions on KDE not providing a configure script anymore...)<br>

<div class="im"><br>
&gt; There will never be an easy way to pull external projects directly into a<br>
&gt; calling project because the external things are not even guaranteed to be on<br>
&gt; disk yet at configure time of said calling project.<br>
<br>
<br>
</div>Yeah, kind of a chicken-egg problem...<br></blockquote><div><br></div><div>Exactly. That&#39;s why we didn&#39;t try to solve that problem. If you have a chicken-egg problem to solve, you have to choose starting with a chicken or an egg, thereby alienating approximately 50% of your audience, even if you have good reasons for your choice.</div>
<div><br></div><div>So: there is one approach that&#39;s sort of a hybrid here, that I&#39;ll mention because it might be useful to consider.</div><div><br></div><div>You could have a cmake option in your project that builds your project one of two ways: &quot;as usual&quot; or as the final link in a chain of ExternalProject_Add calls. I&#39;ve done this and I know it works, but it&#39;s proprietary and I cannot point you to the source code. This technique, however, does make things hard to think about at times...</div>
<div><br></div><div>Something like this in CMakeLists.txt:</div><div>==================================================</div><div>option(MYPROJ_UBERBUILD &quot;If ON, build all prereqs first, then build me...&quot; ON)</div>
<div>if(uberbuild)</div><div>  include(BuildAllViaExternalProject.cmake)</div><div>else()</div><div>  include(BuildJustMe.cmake)</div><div>endif()</div><div><br></div><div>And as the last thing inside BuildAllViaExternalProject.cmake:<br>
</div><div>==================================================</div><div>ExternalProject_Add(</div><div>  DOWNLOAD_COMMAND &quot;&quot;</div><div>  CMAKE_ARGS</div><div>    -DMYPROJ_UBERBUILD:BOOL=OFF</div><div>  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}</div>
<div>  ...</div><div>)</div><div><br></div><div><br></div><div>The net effect is that a project can build itself as an ExternalProject with the &quot;clever (?)&quot; use of a CMake option....</div><div><br></div><div><br>
</div><div>HTH,</div><div>David</div><div><br></div></div>