[cmake-developers] Is it possible to clone an existing target?

Stanislav Pankevich s.pankevich at gmail.com
Wed Mar 22 09:53:48 EDT 2017


Hi Brad,

Thanks for the answer.

Yes, I am going to write my own macro which, I hope, will do the job for
the most cases.

My use case is to generate the LLVM bitcode artefacts *.bc from existing
CMake target instead of a binary that it would produce by default. Cloning
existing target and then patching its settings will help me to maintain
both original and patched versions of a library targets.

I think this feature might be very useful for all R&D projects that do all
sorts of analysis or transformations based on LLVM IR: instead of a normal
process of compilation of everything then linking, such project just
consumes a collection of *.bc files and then does some useful work with it.
It is definitely the attempt to use CMake slightly beyond its normal use
case.

For full background please see my other related question:

https://cmake.org/pipermail/cmake-developers/2017-January/029788.html

Thanks,

Stan

On Wed, Mar 22, 2017 at 1:06 PM, Brad King <brad.king at kitware.com> wrote:

> On 03/22/2017 03:30 AM, Stanislav Pankevich wrote:
> > I have a target `MyTarget`. Is there a way I could do something like
> >
> > clone_target(MyTarget MyNewTarget)
> >
> > so that MyNewTarget appears to be the exact clone (deep copy)
> > of original target with the only difference of a target name?
>
> There is no builtin way to do that, though you might be able to
> get close with a macro that reads target properties from the
> original in order to reproduce them with appropriate commands.
>
> What is your use case?
>
> -Brad
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20170322/1ae7ea5f/attachment.html>


More information about the cmake-developers mailing list