User-overriding IMPORTED targets (overlaying libraries, ...)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

User-overriding IMPORTED targets (overlaying libraries, ...)

Ivan Shapovalov
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 /
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: User-overriding IMPORTED targets (overlaying libraries, ...)

Stephen Kelly-2
Ivan Shapovalov wrote:

> 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?

After

 find_package(Foo CONFIG)

do

 set_property(TARGET Foo::Foo PROPERTY LOCATION "foo_overlay.so")

Apply whatever platform-specific conditions, suffix and prefix are
appropriate.

Thanks,

Steve.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: User-overriding IMPORTED targets (overlaying libraries, ...)

Ivan Shapovalov
On 2016-09-01 at 18:57 +0200, Stephen Kelly wrote:

> Ivan Shapovalov wrote:
>
> >
> > 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?
>
> After 
>
>  find_package(Foo CONFIG)
>
> do
>
>  set_property(TARGET Foo::Foo PROPERTY LOCATION "foo_overlay.so")
>
> Apply whatever platform-specific conditions, suffix and prefix are 
> appropriate.
Yes, I thought of this, but I'd better avoid patching either project's
buildsystem. Is it possible to do this entirely by installing new files
or passing arguments in cmake command line?

Thanks,
--
Ivan Shapovalov / intelfx /
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

signature.asc (817 bytes) Download Attachment