[cmake-developers] explicit custom command side-effects (was: Severe regression caused by #14972 fixes)
Brad King
brad.king at kitware.com
Wed Oct 8 10:26:44 EDT 2014
On 10/08/2014 09:55 AM, Adam Strzelecki wrote:
> We lack OUTPUT for add_custom_target.
>
> I can work on OUTPUT support for add_custom_target if you want?
This is not just about add_custom_target, and it is not about OUTPUT.
Custom targets have no explicit output by design, but they can have
DEPENDS on custom commands that have outputs.
Both add_custom_target and add_custom_command can run operations that
produce side-effects. Both commands need a way to specify any side
effects they produce. Perhaps a new option like "GENERATES" can be
added for this. For example:
add_custom_target(Provider
COMMAND some-generator -o side-effect
GENERATES side-effect
)
or:
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generator-stamp.txt
COMMAND some-generator -o side-effect
COMMAND ${CMAKE_COMMAND} -E touch generator-stamp.txt
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generator-input.txt
GENERATES side-effect
)
The GENERATES value(s) would be marked with the GENERATED property.
For Ninja we would add extra outputs to the generated rule and
ask Ninja to restat them to avoid the always-rebuild case. For
other generators no additional build system content is needed.
> Together with new POLICY it will make sense, unless you have other
> opinion on that.
We need some kind of transition plan that may or may not be a policy.
Let's get the design of the new interface done first.
> But I guess it won't make it to 3.1?
Absolutely not for 3.1. The feature freeze for it is upon us NOW
and we haven't even started the design for the new behavior yet.
We have plenty of time before 3.2 though to get it right.
-Brad
More information about the cmake-developers
mailing list