I did actually get that working.<div><br></div><div>However, I also found a _much simpler_ way of doing this.</div><div><br></div><div>In liba/CMakeLists.txt:</div><div><br></div><div><div># Self</div><div>set(A_INCLUDE_DIRS ${A_INCLUDE_DIRS} &quot;${PROJECT_SOURCE_DIR}/include&quot;)</div>
<div>set(A_LIBRARIES ${A_LIBRARIES} &quot;${PROJECT_BINARY_DIR}/liba.a&quot;)</div><div><br></div><div># Libpng</div><div>FIND_PACKAGE(libpng REQUIRED)</div><div>set(A_INCLUDE_DIRS ${A_INCLUDE_DIRS} ${LIBPNG_INCLUDE_DIRS})</div>
<div>set(A_LIBRARIES ${A_LIBRARIES} ${LIBPNG_LIBRARIES})</div><div><br></div><div>ADD_LIBRARY(a ${SOURCES})</div><div><br></div><div># Includes</div><div>INCLUDE_DIRECTORIES(${A_INCLUDE_DIRS})</div><div><br></div><div># Allow other projects to use this</div>
<div>configure_file(<a href="http://AConfig.cmake.in">AConfig.cmake.in</a> &quot;${PROJECT_BINARY_DIR}/AConfig.cmake&quot;)</div></div><div><br></div><div>In liba/AConfig.cmake:</div><div><div>set(A_LIBRARIES @A_LIBRARIES@)</div>
<div>set(A_INCLUDE_DIRS @A_INCLUDE_DIRS@)</div><div><br></div><div>In dummy/CMakeLists.txt:</div><div>FIND_PACKAGE(A REQUIRED)</div><div>INCLUDE_DIRECTORIES(${A_INCLUDE_DIRS})</div><div>TARGET_LINK_LIBRARIES(dummy ${A_LIBRARIES})</div>
<div><br></div><div>This yields an AConfig.cmake that reads:</div><div><div>set(A_LIBRARIES /home/doug/projects/dummy/deps/liba/build/liba.a;/usr/lib/libpng.so)</div><div>set(A_INCLUDE_DIRS /home/doug/projects/dummy/deps/liba/include;/usr/include)</div>
</div><div><br></div><div>And a verbose compile that reads:</div><div>/usr/bin/gcc  -std=c99 -g   CMakeFiles/dummy.dir/src/main.c.o  -o dummy -rdynamic ../deps/liba/build/liba.a -lpng </div><div>                                        </div>
</div><div>Which is exactly what I was looking for.</div><div><br></div><div>I&#39;m sure there are lots of things wrong with this (specifically; installing won&#39;t work) but for a library that is never going to installed, it&#39;s great.</div>
<div><br></div><div>Thanks for all your help~</div><div><br></div><div>Cheers,</div><div>Doug.<br><br><div class="gmail_quote">On Sat, Aug 13, 2011 at 3:35 PM, 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;"><div class="im">On Sat 13 Aug 2011 03:55:06 AM CEST, Doug wrote:<br>
&gt; I see.<br>
&gt;<br>
&gt; I&#39;ve tried this approach and I get the error:<br>
&gt; -- Found LIBPNG<br>
&gt; CMake Error at CMakeLists.txt:49 (export):<br>
&gt;   export given target &quot;/usr/lib/libpng.so&quot; which is not built by this<br>
&gt;   project.<br>
&gt;<br>
&gt;<br>
&gt; -- Configuring incomplete, errors occurred!<br>
&gt;<br>
&gt; ~<br>
&gt; Doug.<br>
&gt;<br>
&gt; On Fri, Aug 12, 2011 at 4:57 PM, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     On Fri 12 Aug 2011 10:49:45 AM CEST, Doug wrote:<br>
&gt;     &gt; I&#39;m sorry if I&#39;m being dumb here, but I fail to see how that helps.<br>
&gt;     &gt;<br>
&gt;     &gt; That example is one where foobar depends explicitly on foo and bar.<br>
&gt;     &gt;<br>
&gt;     &gt; What if foo depends on bar2?<br>
&gt;     &gt;<br>
&gt;     &gt; How do I inherit that dependency from foo in foobar?<br>
&gt;     &gt;<br>
&gt;     &gt; _that&#39;s_ what I&#39;m looking for.<br>
&gt;     &gt;<br>
&gt;     &gt; (If that example somehow explains that, I&#39;m sorry, I can&#39;t see it. Can<br>
&gt;     &gt; you point to a specific point in the page?)<br>
&gt;     &gt;<br>
&gt;     &gt; ~<br>
&gt;     &gt; Doug.<br>
&gt;     &gt;<br>
&gt;     &gt; On Fri, Aug 12, 2011 at 2:34 PM, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a><br>
&gt;     &lt;mailto:<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt;<br>
</div><div class="im">&gt;     &gt; &lt;mailto:<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a> &lt;mailto:<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt;&gt;&gt; wrote:<br>
&gt;     &gt;<br>
&gt;     &gt;     If the projects are independent, you might want to take a look<br>
&gt;     at this<br>
&gt;     &gt;     Wiki page:<br>
&gt;     &gt;<br>
&gt;     <a href="http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file" target="_blank">http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file</a>.<br>
&gt;     &gt;<br>
&gt;     &gt;     HTH<br>
&gt;     &gt;<br>
&gt;     &gt;     Michael<br>
&gt;     &gt;<br>
&gt;<br>
&gt;     And that is what the example is *about*. The FooBar project *exports*<br>
&gt;     its targets, along with their dependencies, so that when other projects<br>
&gt;     do find_package(FooBar), they will be able to link against the foo<br>
&gt;     library without having to know any of the dependencies of it. E.g. the<br>
&gt;     project &quot;hello&quot; might look like this:<br>
&gt;<br>
&gt;     project(hello)<br>
&gt;     find_package(FooBar REQUIRED)<br>
&gt;     include_directories(${FOOBAR_INCLUDE_DIRS})<br>
&gt;     add_executable(hello hello.c)<br>
&gt;     target_link_libraries(hello ${FOOBAR_LIBRARIES})<br>
&gt;<br>
&gt;<br>
&gt;     Michael<br>
<br>
</div>Did you do something like this?<br>
<br>
export(TARGETS /usr/lib/libpng.so)<br>
<br>
That would be wrong... You do it like this<br>
<br>
find_package(PNG REQUIRED)<br>
add_library(foo SHARED foo.c)<br>
target_link_libraries(foo ${PNG_LIBRARIES})<br>
install(TARGETS foo EXPORT FooLibraryDepends<br>
  RUNTIME DESTINATION bin<br>
  LIBRARY DESTINATION lib)<br>
export(TARGETS foo FILE &quot;${PROJECT_BINARY_DIR}/FooLibraryDepends.cmake&quot;)<br>
<font color="#888888"><br>
<br>
Michael<br>
</font></blockquote></div><br></div>