<p dir="ltr">Yes, Pau, this is exactly my problem. Or more specifically, as the author of a library that uses CMake and depends on libpcap, how can I best structure and distribute the library to make it easy to use (and cross compile)?  I would say using the system libpcap is strongly preferred over distributing a copy of it.</p>
<p dir="ltr">That tutorial is very interesting.  I'll have to take a closer look at it because the solution isn't jumping out at me.  The tutorial shows a project that contains both a library and a program that links to that library in the same list file.  In my case that would not be possible.  Also, the library in the example has no dependencies so it wouldn't suffer from the absolute path issue I'm encountering.</p>
<div class="gmail_quote">On Oct 19, 2015 5:36 PM, "Pau Garcia i Quiles" <<a href="mailto:pgquiles@elpauer.org">pgquiles@elpauer.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dan,<div><br></div><div>On a second read, it seems Zac's problem was actually finding the dependency (libpcap) of a dependency. Or rather, making if findable, because the second depenency contains an absolute path which is broken due to cross-compilation.</div><div><br></div><div>I have never used it but this page contains information on how to fix the paths in the config file to be relative instead of absolute. That should fix the problem:</div><div><br></div><div><a href="https://cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file" target="_blank">https://cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file</a><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 19, 2015 at 11:15 PM, Dan Kegel <span dir="ltr"><<a href="mailto:dank@kegel.com" target="_blank">dank@kegel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well, that's one answer.  But if you want to use system libpcap, it's not a very satisfying one.<div><br></div><div>It's odd that pcap doesn't ship with a .pc file.   </div><div>I guess the pcap folks are hostile to pkgconfig because it's LGPL; see</div><div><a href="https://github.com/the-tcpdump-group/libpcap/issues/374" target="_blank">https://github.com/the-tcpdump-group/libpcap/issues/374</a><span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>- Dan<br></div><div><br></div><div><br></div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 19, 2015 at 2:04 PM, Pau Garcia i Quiles <span dir="ltr"><<a href="mailto:pgquiles@elpauer.org" target="_blank">pgquiles@elpauer.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>Use ExternalProject to build libpcap as part of your project. Make sure you use $ORIGIN in rpath everywhere. Install your application (and your bundled libpcap) to /opt to avoid polluting the system.</div></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Mon, Oct 19, 2015 at 10:37 PM, Zac Bergquist <span dir="ltr"><<a href="mailto:zbergquist99@gmail.com" target="_blank">zbergquist99@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you for your reply, Guillaume.<div><br></div><div>I understand that this is the expected behavior.  I even linked to the documentation that says this is the expected behavior.  What I don't understand is how to resolve it.  Are you saying it is not possible to create a relocatable package unless all dependencies are also using CMake?  That doesn't seem right.</div><div><br></div><div>Should I be trying to write a package config file for libpcap, or is there a better way to approach this?</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 17, 2015 at 8:19 AM, Guillaume Dumont <span dir="ltr"><<a href="mailto:dumont.guillaume@gmail.com" target="_blank">dumont.guillaume@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">What you are seeing is the expected behavior. You can get a relocatable package if all your dependencies (in your case libcap) have themselves relocatable package config files with exported targets. Then you package should make use of find_dependency macro.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Oct 16, 2015 at 4:56 PM, Zac Bergquist <span dir="ltr"><<a href="mailto:zbergquist99@gmail.com" target="_blank">zbergquist99@gmail.com</a>></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 dir="ltr">I've created a sample project to replicate my issue in hopes that it would make it easier to troubleshoot.<div><br></div><div>Thanks for any help,</div><div>Zac<br><div><br></div><div><a href="https://github.com/zmb3/cmaketest" target="_blank">https://github.com/zmb3/cmaketest</a><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 12, 2015 at 8:53 AM, Zac Bergquist <span dir="ltr"><<a href="mailto:zbergquist99@gmail.com" target="_blank">zbergquist99@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I'm trying to fix a project so that its output is relocatable.  The project is a library that itself depends on libpcap.  My goal is to be able to import the library into my CMake application and have CMake automatically link libpcap with it.</div><div><br></div><div>I'm using a toolchain file that invokes an ARM cross compiler, sets CMAKE_INSTALL_PREFIX and appends it to CMAKE_FIND_ROOT_PATH.  This all seems to work well.</div><div><br></div><div>What I'm seeing is that the exported files that get installed to CMAKE_INSTALL_PREFIX contain absolute paths to libpcap on my machine, which make them useless to other team members.</div><div><br></div><div>The first thing I changed was to use CONFIGURE_PACKAGE_CONFIG_FILE instead of CONFIGURE_FILE.  This got rid of absolute paths in the generated CMake config file.</div><div><div><br></div><div>However, I still have absolute paths in the CMake target import file that gets generated.  The IMPORTED_LINK_INTERFACE_LIBRARIES target property has an absolute path instead of one relative to CMAKE_INSTALL_PREFIX.</div><div><br></div><div>I've read the "Creating Relocatable Packages" [1] section of the CMake packages documentation. I'm pretty sure this is what I'm running into, but I don't quite understand how to solve it.  The documentation says that I should be using imported targets, but I'm not sure how to do so.  The library is just using its own FindPCAP.cmake file to locate libpcap.</div></div><div><br></div><div>Does anyone know of an example of a CMake package that imports other libraries?  I could also try to create a minimal example project with this setup if it would be helpful.</div><div><br></div><div>Thanks,</div><div>Zac</div><div><br></div><div>[1]: <a href="https://cmake.org/cmake/help/v3.3/manual/cmake-packages.7.html#creating-relocatable-packages" target="_blank">https://cmake.org/cmake/help/v3.3/manual/cmake-packages.7.html#creating-relocatable-packages</a></div><div><br></div></div>
</blockquote></div><br></div>
<br></div></div>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><span><font color="#888888"><br></font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Guillaume Dumont<br>=========================<br><a href="mailto:dumont.guillaume@gmail.com" target="_blank">dumont.guillaume@gmail.com</a></div>
</font></span></div>
</blockquote></div><br></div>
</div></div><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br></div></div><span><font color="#888888"><div>Pau Garcia i Quiles<br><a href="http://www.elpauer.org" target="_blank">http://www.elpauer.org</a><br>(Due to my workload, I may need 10 days to answer)</div>
</font></span></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Pau Garcia i Quiles<br><a href="http://www.elpauer.org" target="_blank">http://www.elpauer.org</a><br>(Due to my workload, I may need 10 days to answer)</div>
</div>
</blockquote></div>