[CMake] User-overriding IMPORTED targets (overlaying libraries, ...)

Ivan Shapovalov intelfx at intelfx.name
Wed Aug 31 07:57:34 EDT 2016


Hello,

Let's suppose I have a project Foo which generates a shared library
`libfoo.so`, and a project Bar which links to `foo` and builds an
executable `bar`.

Let's also suppose that as a maintainer, I wrote a library
`libfoo_overlay.so` which links to `libfoo.so` and redefines certain
symbols in that library (e. g. for hardware-specific optimizations
which cannot be upstreamed).

If the projects use the traditional find_package() module mode approach
to find `foo`, then the FindFoo.cmake module will most likely define a
CACHED variable Foo_LIBRARY, which I can then edit with ccmake,
pointing it to `libfoo_overlay.so` instead of `libfoo.so`. This way, I
do not need to patch either project's buildsystem, which is nice.

However, if the two projects use a more-modern approach with config
mode find_package() and IMPORTED targets, then I have no way to edit
the definition of `foo` imported target to alter its LOCATION, because
the target definition itself is not cached.

Of course, I can always edit the FooConfig.cmake file manually, but I'd
better avoid patching anything (installing new files or running any
cmake commands is OK).

Is there any nice way to solve this?

-- 
Ivan Shapovalov / intelfx /
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160831/f6625eb2/attachment.sig>


More information about the CMake mailing list