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

Egor Pugin egor.pugin at gmail.com
Wed Mar 22 10:38:25 EDT 2017


Aliases for imported targets also would be useful.
I found some old email threads, but seems they had not been implemented.

On 22 March 2017 at 16:53, Stanislav Pankevich <s.pankevich at gmail.com> wrote:
> 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
>>
>
>
> --
>
> 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-developers



-- 
Egor Pugin


More information about the cmake-developers mailing list