<div class="gmail_quote">On Fri, Jun 22, 2012 at 11:33 AM, Kent Williams <span dir="ltr"><<a href="mailto:nkwmailinglists@gmail.com" target="_blank">nkwmailinglists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Say I have an ExternalProject that generates several libraries<br>
<br>
ExternalProject_Add(foo<br>
# the usual mumbo jumbo<br>
)<br>
<br>
set(foo_LIBRARIES)<br>
<br>
# foo makes 3 libraries<br>
foreach(lib a b c)<br>
# import the libraries<br>
add_library(${lib} STATIC IMPORTED)<br>
<br>
# tell CMake where the library file is<br>
set_property(TARGET ${lib} PROPERTY<br>
IMPORTED_LOCATION<br>
${imported_library_filename})<br>
<br>
# add to the library list<br>
list(APPEND foo_LIBRARIES ${lib})<br>
<br>
# this doesn't work apparently<br>
add_dependencies(${lib} foo)<br>
endforeach()<br>
<br>
In order for parallel make to work, the foo ExternalProject must<br>
complete successfully before any programs that link to<br>
${foo_LIBRARIES} are compiled and linked.<br>
<br>
I thought that making the imported library targets depend on the<br>
ExternalProject target would behave in a transitive manner - i.e.<br>
<br>
add_executable(foo_user foo.cxx)<br>
target_link_libraries(foo_user ${foo_LIBRARIES})<br>
<br>
But this is not the case. In a parallel build, the foo_user build<br>
doesn't wait for the foo ExternalProject to finish.<br>
<br>
If I add<br>
<br>
add_dependencies(foo_user foo)<br>
<br>
Everything behaves fine. But that requires explicitly add a<br>
dependency on an ExternalProject target everywhere it's outputs are<br>
used.<br>
<br>
Is this a bug? A feature request? Or is there another way to make this work?<br></blockquote><div><br></div><div><br></div><div>It's neither a bug nor a feature request, it's just the way it works. The explicit dependency is the only way to connect up the outputs of one ExternalProject call to another, which by their nature are independent of one another unless explicitly connected via arguments / cache entries.</div>
<div><br></div><div>If you want foo_user to depend on the actual libraries, then it should be its own project that does a find_package(foo) to get them. And then *also* have a SuperBuild that builds foo and then foo_user, where foo_user as an ExternalProject depends on foo as an ExternalProject.</div>
<div><br></div><div>The best way to use ExternalProject is to have a SuperBuild project that builds *everything* as an ExternalProject.</div><div><br></div><div>It's not easy (or advisable, in my thinking) to combine ExternalProject calls with non-ExternalProject CMake targets. That's why I recommend a SuperBuild, with exclusively ExternalProject targets, as the best bet.</div>
<div><br></div><div><br></div><div>HTH,</div><div>David</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
--<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>