add_dependencies does work to make sure that ExternalProject targets build before internal targets, if you need that.<div><br></div><div>But, like Marcus said, you probably need the ExternalProject to be configured and built before your own calls to find_package... so if you have that chicken and egg problem, you should also build your project as an ExternalProject.</div>
<div><br></div><div>Almost all of the projects I know of that are using ExternalProject are producing a so-called &quot;SuperBuild&quot; of themselves, wherein all the targets of the SuperBuild are ExternalProject_Add calls, and the last one is the &quot;project of interest.&quot;</div>
<div><br></div><div><br></div><div>HTH,</div><div>David</div><div><br><br><div class="gmail_quote">On Wed, Jan 12, 2011 at 2:09 PM, Allen D Byrne <span dir="ltr">&lt;<a href="mailto:byrn@hdfgroup.org">byrn@hdfgroup.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="font-family:&#39;Sans Serif&#39;;font-size:12pt;font-weight:400;font-style:normal">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">While Marcus states what is likely the preferred way, I just added an ADD_DEPENDENCIES(internal_target external_target) statement that seems to always work?</p>

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Allen</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Date: Wed, 12 Jan 2011 13:23:52 -0500</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; From: &quot;Marcus D. Hanwell&quot; &lt;<a href="mailto:marcus.hanwell@kitware.com" target="_blank">marcus.hanwell@kitware.com</a>&gt;</p>

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Subject: Re: [CMake] How to have a target depend on an External</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt;         Project</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; To: kent williams &lt;<a href="mailto:nkwmailinglists@gmail.com" target="_blank">nkwmailinglists@gmail.com</a>&gt;</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Cc: CMake ML &lt;<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>&gt;</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Message-ID:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt;         &lt;AANLkTinDoc6guEnK7rxQ=<a href="mailto:0yy%2BsXacOium52iX8ZiHmcz@mail.gmail.com" target="_blank">0yy+sXacOium52iX8ZiHmcz@mail.gmail.com</a>&gt;</p>

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Content-Type: text/plain; charset=ISO-8859-1</p><div><div></div><div class="h5">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; On Wed, Jan 12, 2011 at 12:53 PM, kent williams</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &lt;<a href="mailto:nkwmailinglists@gmail.com" target="_blank">nkwmailinglists@gmail.com</a>&gt; wrote:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; For better or worse (mostly better) we are now heavy users of</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; ExternalProject. ?That module works really well to pull in external</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; dependencies and get them built.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt;</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; ExternalProject_add has a DEPENDS keyword that lets you specify</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; dependencies on other External Projects. ?But an ExternalProject isn&#39;t</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; an actual CMake target, so I can&#39;t figure out how to make a regular</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; CMake target depend on an External Project.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt;</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; &gt; Suggestions?</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Don&#39;t mix external projects and real targets. An external project</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; dependency is different to a target dependency. When expressing</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; external project dependencies you are stating that this external</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; project needs these others to be built before it is even configured.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; With regular targets there is an assumption that the dependency is</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; part of the current build, and so CMake knows everything about it, or</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; it was already built. If you have Qt in an external project, and a Qt</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; based application depending on it, the find_package(Qt4) will fail</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; during initial configure, as there is no Qt built/installed.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Instead you would normally have your own project as an external</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; project that depends on the others it requires to build. That way,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; when your external project is configured the others will have been</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; built and therefore could be found.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; I hope that makes the mechanism a little clearer. You could take a</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; look at the Titan project as one example where we have many external</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; projects that we build, and the Libraries/Applications external</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; projects that depend upon them and use them.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; Marcus</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">&gt; </p></div></div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</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>
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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br></div>