Re: [CMake] Creating relocatable packages

2015-10-21 Thread Guillaume Dumont
Great! Always happy to help! On Tue, Oct 20, 2015 at 9:58 AM, Zac Bergquist wrote: > Yes, that was exactly what I needed. > > Now my installed targets file has IMPORTED_LINK_INTERFACE_LIBRARIES "PCAP" > instead of an absolute path, and the FindPCAP.cmake module kicks in and > does what I would e

Re: [CMake] Creating relocatable packages

2015-10-20 Thread Zac Bergquist
Yes, that was exactly what I needed. Now my installed targets file has IMPORTED_LINK_INTERFACE_LIBRARIES "PCAP" instead of an absolute path, and the FindPCAP.cmake module kicks in and does what I would expect. Thanks again for your time - much appreciated. Zac On Tue, Oct 20, 2015 at 9:25 AM, G

Re: [CMake] Creating relocatable packages

2015-10-20 Thread Guillaume Dumont
Hi Zac, target_link_libraries will work with either full library paths or target names including imported targets. You need to use target_link_libraries in your CMakeLists.txt and find_dependency in your PackageConfig.cmake. Like so: in CMakeLists.txt: target_link_libraries(mylib ${PCAP_LIBRARI

Re: [CMake] Creating relocatable packages

2015-10-20 Thread Zac Bergquist
I think I'm on the right track now. I was definitely missing the add_library(PCAP IMPORTED) section. Could you elaborate on the last part? I thought target_link_libraries() is the reason I'm getting absolute paths. Should I be using the FindDependency macro instead of target_link_libraries()?

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Guillaume Dumont
Hi Zac, Sorry I read your post very quickly the first time... If your library uses its own FindPCAP.cmake then you can define an imported target for the PCAP libraries like so: # FindPCAP.cmake find_path(PCAP_INCLUDE_DIR pcap.h ... ) find_library(PCAP_LIBRARY pcap ... ) include(FindPackageHandl

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Pau Garcia i Quiles
Hello, In your case, what you need to do is to modify the config file generation in the library (i. e. you will need to patch the third-party library) so that the generated config file is relative. As an alternative, if you do not want to patch the third-party library, try modifying the generated

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Zac Bergquist
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 distributin

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Dan Kegel
I had a look at his example, but stopped at the 'export' line. That's just black magic to me :-) CMake user package registry? Yikes. I stopped trying to use cmake for uberbuilds several years ago. - Dan On Mon, Oct 19, 2015 at 2:35 PM, Pau Garcia i Quiles wrote: > Hi Dan, > > On a second read

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Pau Garcia i Quiles
Hi Dan, 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. I have never used it but this page contains information o

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Dan Kegel
Well, that's one answer. But if you want to use system libpcap, it's not a very satisfying one. It's odd that pcap doesn't ship with a .pc file. I guess the pcap folks are hostile to pkgconfig because it's LGPL; see https://github.com/the-tcpdump-group/libpcap/issues/374 - Dan On Mon, Oct 19,

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Pau Garcia i Quiles
Hello, 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. On Mon, Oct 19, 2015 at 10:37 PM, Zac Bergquist wrote: > Thank you for your reply, Guill

Re: [CMake] Creating relocatable packages

2015-10-19 Thread Zac Bergquist
Thank you for your reply, Guillaume. 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 dependenci

Re: [CMake] Creating relocatable packages

2015-10-17 Thread Guillaume Dumont
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. On Fri, Oct 16, 2015 at 4:56 PM, Zac Ber

Re: [CMake] Creating relocatable packages

2015-10-16 Thread Zac Bergquist
I've created a sample project to replicate my issue in hopes that it would make it easier to troubleshoot. Thanks for any help, Zac https://github.com/zmb3/cmaketest On Mon, Oct 12, 2015 at 8:53 AM, Zac Bergquist wrote: > Hello, > > I'm trying to fix a project so that its output is relocatable

[CMake] Creating relocatable packages

2015-10-12 Thread Zac Bergquist
Hello, 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. I'm using a toolchain file that invokes an ARM