[cmake-developers] cmake --help-policy CMP0057 MAIN_DEPENDENCY
Nils Gladitz
nilsgladitz at gmail.com
Wed Apr 29 03:11:11 EDT 2015
On 28.04.2015 16:50, James Bigler wrote:
> Why are we making the restriction more restrictive than it needs to
> be? We only need this for multiple targets and not within a single
> target.
>
I wasn't aware of that use case and I misdiagnosed the underlying issue
as well.
The issue isn't having multiple custom commands listing the same
MAIN_DEPENDENCY but rather having more than one target refer to a source
file that is listed as a MAIN_DEPENDENCY.
The policy will likely have to be removed or replaced.
> Ideally what should happen is:
> 1. MAIN DEPENDENCY issues cross targets should automatically be
> downgraded to DEPENDENCY with a warning.
>
> I'm also curious why specifying MAIN DEPENDENCY in make file
> generators has any special effect since according the documentation
> there be no functional difference. It seems like this is more a bug in
> how MAIN DEPENDENCY is being handled. Using warnings and errors to
> correct this seems a bit like the wrong solution.
>
It seems to be like this ...
a) A custom command (with OUTPUT) without MAIN_DEPENDENCY attaches the
command to the OUTPUT source file (or rather rule file associated with
the first output).
b) A custom command (with OUTPUT) with MAIN_DEPENDENCY attaches the
command to the input (MAIN_DEPENDENCY) source file.
This so far is generic and not generator specific.
For every target the makefile generator iterates over all source files
and emits their attached commands.
For case a) this breaks if an OUTPUT is listed in more than one target.
For case b) this breaks if a MAIN_DEPENDENCY is listed in more than one
target.
This also means that MAIN_DEPENDENCY can probably not be downgraded to
DEPENDENCY automatically since existing projects might not list both
output and input in their targets.
Nils
More information about the cmake-developers
mailing list