[CMake] command in add_custom_command launched even if output not stale

Ruslan Baratov ruslan_baratov at yahoo.com
Wed Feb 4 13:16:15 EST 2015


All OUTPUT files O0, O1, O2,... depends on all DEPENDS files I0, I1, I2,...

See this discussion: 
http://www.cmake.org/pipermail/cmake/2014-October/058824.html

On 04-Feb-15 17:14, CREMARENCO Cosmin wrote:
>
> Hello,
>
> We use CMake and among other things CMake is used for generating code 
> at compilation time.
>
> We have a custom command like so:
>
> add_custom_command(OUTPUT O0, O1, O2…On
>
> launch-generation-command
>
>  DEPENDS I0, I1, I2, ….In
>
>    VERBATIM)
>
> So there are multiple inputs and multiple outputs (why not launch the 
> command for each input and have only one output? – it would take too 
> much time combined, a jvm is launched every time and there are a lot 
> of generated files).
>
> The command that is launched is intelligent enough to not touch output 
> if its corresponding input has not changed.
>
> Now I’m coming to the problem: when I touch an input Ix, I expect that 
> output Ox is regenerated. That works great, make will launch the 
> custom command and Ox will be generated and compiled afterwards. But, 
> subsequent runs of make will still launch the custom command which is 
> not ok. By digging in the generated Makefiles I see that cmake will 
> hang the custom command under one of the outputs (arbitrarily?). If 
> that output is not exactly the input that I touch, given that the 
> generator will only output code for what has really changed, the 
> target will always be invalid and make will always launch the custom 
> command. Is there a solution for this?
>
> It seems obvious to me that if the oldest output is more recent than 
> the newest input then the custom command shouldn’t be called.
>
> Visual Studio is even worse. Besides launching the custom command 
> every time, it will recompile all outputs because, my guess is that 
> after the custom command has run it won’t even bother to check that 
> the .obj is more recent than the corresponding .cpp.
>
> Sorry for the somewhat terse mail and thanks in advance!
>
> Cosmin
>
> *******************************
>
> This e-mail contains information for the intended recipient only. It 
> may contain proprietary material or confidential information. If you 
> are not the intended recipient you are not authorised to distribute, 
> copy or use this e-mail or any attachment to it. Murex cannot 
> guarantee that it is virus free and accepts no responsibility for any 
> loss or damage arising from its use. If you have received this e-mail 
> in error please notify immediately the sender and delete the original 
> email received, any attachments and all copies from your system.
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150204/8e6d0cbd/attachment.html>


More information about the CMake mailing list