Commit dccd4949 authored by Brad King's avatar Brad King
Browse files

Use first custom command for the same output (#14446)

In buggy code like


that has more than one rule to generate the same output CMake has always
used the first rule.  However, since commit 2268c41a (Optimize custom
command full-path dependency lookup, 2013-08-06) we update the map from
output to cmSourceFile for every rule generating an output, effectively
keeping the last command instead of the first.

Fix this regression by checking for each map update if the output
already has an entry.  If so, keep only the original entry.  The VS 8
generator triggers this with a special case for generate.stamp rules
that differ between ZERO_CHECK and normal targets, so do not warn for
now.  Leave a TODO comment for warning in the future.
parent 2268c41a
......@@ -1033,6 +1033,19 @@ void
cmMakefile::UpdateOutputToSourceMap(std::string const& output,
cmSourceFile* source)
OutputToSourceMap::iterator i = this->OutputToSource.find(output);
if(i != this->OutputToSource.end())
// Multiple custom commands produce the same output but may
// be attached to a different source file (MAIN_DEPENDENCY).
// LinearGetSourceFileWithOutput would return the first one,
// so keep the mapping for the first one.
// TODO: Warn the user about this case. However, the VS 8 generator
// triggers it for separate generate.stamp rules in ZERO_CHECK and
// individual targets.
this->OutputToSource[output] = source;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment