[CMake] exclude a dependency from export

Jack Stalnaker omnijack at gmail.com
Fri Jan 22 10:14:27 EST 2016


Is there any way to exclude a dependency from an export? If I build a
static library target "A" but do not wish to install it, and then link that
target to another target "B" using target_link_libraries(B A), and then
attempt to export B, I get the error message:

install (EXPORT "B" ...) includes target "B" which requires target "A" that
is not in the export set.

I can solve the problem by installing A, but there is no need to. It is a
temporary target that is statically linked. I just need to export for
creating a package config file, so there's no need for the package config
to ever need to worry about statically linked libraries.

Is there a workaround for this?

Long story short, I am trying to replicate convenience libraries from
autotools. I'm having a hell of time doing it. I can use lists of sources,
but that requires passing around global variables that include the sources
and others that include the required libraries. This is far messier and far
less convenient. I've tried object libraries, and while they eliminate the
global source variables and prevent rebuilding things, they fail when the
source is nested, and you want to build a "super library" from smaller
object libraries, which I believe is a fairly common working pattern.
Building a static library that is never installed works really well ...
until I go to create a package config file. Then this export fails.

Thanks,
--Jack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160122/0aca5075/attachment.html>


More information about the CMake mailing list