<div>That works if it&#39;s all in a single project, but it&#39;s not.</div><div><br></div><div>I totally understand you can do this:</div><div><br></div><div>add_library(foo)</div><div>target_link_library(foo bar)</div><div>
add_executable(exec)</div><div>target_link_library(exec foo)</div><div><br></div><div>If you have _this_ structure:</div><div><br></div><div>.../liba/CMakeLists.txt </div><div>....</div><div><br></div><div>.../blah/libb/CMakeLists.txt</div>
<div>....</div><div><br></div><div>..../some/other/path/exec/CMakeLists.txt</div><div><br></div><div>Then in exec you can you use find_package(libb REQUIRED)</div><div><br></div><div>However, when I compile it I still get dependency resolution errors on liba (libpng in my case).</div>
<div><br></div><div>I&#39;m guessing thats because to resolve libb all you get a include path and a library path; find package has no way to load the CMakeLists.txt in libb/ and parse it, add the dependency to liba.</div>
<div><br></div><div>Seems like there should be a way to do this though.</div><div><br></div><div>Am I wrong?</div><div><br></div><div>Should the values in libb&#39;s CMakeLists.txt be propagating through?</div><div><br></div>
<div>If that&#39;s supposed to happen I must be using find_package wrong somehow?</div><div><br></div><div>In my specific case libpng and libpng-android are not the same project; they are completely split and do not even use the same files.</div>
<div><br></div><div>Neither of them are &#39;child&#39; projects of my library (libnw) via add_subdirectory or some other weird thing like that.</div><div><br></div><div>~</div><div>Doug.</div><div><br></div><div><div class="gmail_quote">
On Thu, Aug 11, 2011 at 9:30 PM, Glenn Coombs <span dir="ltr">&lt;<a href="mailto:glenn.coombs@gmail.com">glenn.coombs@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;">
The target_link_libraries() command would be in the CMakeLists.txt for library A, not the one for your executable.  The one for your executable would just say target_link_libraries(myExe A).  And cmake would automatically know that linking with A also means linking with png.<br>

<br>You say that you have 2 different versions of library A.  Does this mean that you have 2 separate CMakeLists.txt files, one for each variant of A.  Or are both variants built by the same CMakeLists.txt ?  Either way, I would have thought that you could add the appropriate target_link_libraries() command.  Can you describe your current setup in a bit more detail to explain why this approach won&#39;t work ?<div>
<div></div><div class="h5"><br>
<br><div class="gmail_quote">On 11 August 2011 14:02, Doug <span dir="ltr">&lt;<a href="mailto:douglas.linder@gmail.com" target="_blank">douglas.linder@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">

<span style="color:rgb(51, 51, 51);font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)"><div>How can I achieve that _without_ editing my own cmake file?<div><br></div>
<div>What if a swap in a different library for my executable that is abi compatible but uses a different implemented to load images? </div><div><br></div><div>I&#39;m not talking hypotheticals here: I literally have two versions of the library that use slightly different versions of libpng (one for desktop and one for android) and it&#39;s extremely inconvenient to be messing around with my cmake file every time I change my build target.</div>


<div><br></div><div>Sure I can do a giant IF(TARGET MATCHES &quot;Android&quot;) ... ENDIF, which I guess is what I will do for now, but it seems like a poor solution.</div><div><br></div></div><div>Edit: woops; ment that to go to the list.</div>


<div><br></div><div>~</div><div>Doug.</div><font color="#888888"><div><br></div></font></span><div class="gmail_quote"><div>On Thu, Aug 11, 2011 at 7:39 PM, Glenn Coombs <span dir="ltr">&lt;<a href="mailto:glenn.coombs@gmail.com" target="_blank">glenn.coombs@gmail.com</a>&gt;</span> wrote:<br>


</div><div><div></div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add the sub dependencies that library A has with target_link_libraries():<br><br>
    target_link_libraries(A png)<br><br>
--<br>Glenn<br><br><div class="gmail_quote"><div><div></div><div>On 11 August 2011 10:02, Doug <span dir="ltr">&lt;<a href="mailto:douglas.linder@gmail.com" target="_blank">douglas.linder@gmail.com</a>&gt;</span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>Hrm... this seems like something cmake should be able to do, but I don&#39;t know how to make it work.<div>


<br></div><div>
If I have library A, that depends on a library and an executable project that depends on library A, how can the executable project resolve the sub dependencies from A?</div>
<div><br></div><div>Specifically libpng in my case:</div><div><br></div><div>I have a library that depends on libpng.</div><div><br></div><div>I run cmake to build the library no problem.</div><div><br></div><div>Then I try to compile a program that depends on the library and get a heap of errors like:</div>




<div><br></div><div><div> undefined reference to `png_set_read_fn&#39;</div></div><div> etc. etc.</div><div><br></div><div>Presumably this is something about how I depend on the library? I&#39;m using the LibFindMacros, so my cmake module looks like this for the library:</div>




<div><br></div><div><div>include(LibFindMacros)</div><div><br></div><div>find_path(LIBNW_INCLUDE_DIR NAMES nw.h PATHS ${LIBNW_PKGCONF_INCLUDE_DIRS})</div><div><br></div><div>find_library(LIBNW_LIBRARY NAMES nw PATHS ${LIBNW_PKGCONF_LIBRARY_DIRS})</div>




<div><br></div><div>set(LIBNW_PROCESS_INCLUDES LIBNW_INCLUDE_DIR)</div><div>set(LIBNW_PROCESS_LIBS LIBNW_LIBRARY LIBNW_LIBRARIES)</div><div><br></div><div>libfind_process(LIBNW)</div></div><div><br></div><div> I know I can use ADD_SUBDIRECTORY to include stuff for a sub dir, but that isn&#39;t really appropriate in this case.</div>




<div><br></div><div>~</div><div>Doug.</div>
<br></div></div>_______________________________________________<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>
</blockquote></div></div></div><br>
<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></div></blockquote></div><br></div>