[CMake] Post-Build commands on custom targets are always executed?

Michael Hertling mhertling at online.de
Mon Apr 18 00:58:53 EDT 2011


On 04/16/2011 12:05 AM, Oliver Buchtala wrote:
> Am 15.04.2011 23:48, schrieb Michael Hertling:
>> On 04/15/2011 11:22 PM, Oliver Buchtala wrote:
>>> Hi,
>>>
>>> I observe that a custom command attached to a custom target as
>>> POST-BUILD is launched on every build.
>>> Is that true? or is it a misconfiguration on my side?
>>>
>>> Bye,
>>> Oliver
>> A custom target is always out of date, i.e. it is always rebuilt when
>> it is visited - as a prerequisite of another target or due to the ALL
>> clause, e.g., and since the target has been rebuilt, each associated
>> POST_BUILD custom command is rerun. Thus, the behaviour you observed
>> is correct, expected and reasonable, IMO.
>>
>> Regards,
>>
>> Michael
> Yep. That's reasonable.
> 
> Do have a suggestion how to get around a rerun of the post-build?

Prevent the custom target from being visited, i.e. from being checked
if it's up to date since it will be found to be out of date, so the
immediately associated commands - if any - are run as well as the
associated POST_BUILD custom commands.

> Or how would you do a post-build after custom-target without being run
> when custom-target actually did nothing,

What do you mean with a custom target that "actually did nothing"? Not
visited or no own commands? In the former case, the associated custom
commands are not run, of course, but in the latter case, it does not
matter if there are immediately associated commands or not since the
target will be considered as out of date and rebuilt-without-op, and
its POST_BUILD custom commands will be run. In other words: A custom
target - even without own commands - is not good for preventing its
custom commands from being run when the custom target is visited.

> i.e., custom target depends on custom command that did nothing?

The same holds for this kind of dependency, i.e. the visited custom
target will be rebuilt regardless whether the prerequisite custom
command did do something or not, or do you still talk about the
custom-command-associated-with-custom-target dependency?

Regards,

Michael


More information about the CMake mailing list