[CMake] add_custom_command depends on output from add_custom_target

SK sk at metrokings.com
Tue Nov 2 15:28:44 EDT 2010


On Mon, Nov 1, 2010 at 11:25 PM, Rolf Eike Beer <eike at sf-mail.de> wrote:
> Am Monday 01 November 2010 schrieb SK:
>> I know add_custom_target does not produce output as far as CMake is
>> concerned.  My situation is as follows:
>>
>> A traditional make process that I cannot modify produces a target on
>> which I must do some post-processing.
>>
>> I use add_custom_target to force the makefile to always run. I use
>> add_custom_command for my post-processing steps.
>>
>> How do I setup a dependency for the post-processing steps? I don't
>> want to run these steps unless the external make actually updated its
>> target.
>>
>> The add_custom_command cannot use the name of the add_custom_target as
>> a DEPENDS. I tried this and it assumes that the add_custom_target name
>> is just a file and cannot find it.
>
> Please have a look at http://public.kitware.com/Bug/view.php?id=11332 , this
> describes a very similar problem IMHO (and some workarounds).
>
> Eike
>

Thanks Eike and Mike for your help.  I ended up working around this
with a nasty copy_if_different hack.
I'd be much happier with a feature like this in CMake

ADD_CUSTOM_TARGET( OUTPUT foo1 foo2
   COMMAND "make foos"
   [DEPENDS [ALL]] )


More information about the CMake mailing list