Makefiles: Revert "Make build root targets ... recursive"

Revert the main logic change from commit 827da1119e (Makefiles: Make
build root targets "all", "clean" and "preinstall" recursive,
2019-05-17, v3.15.0-rc1~96^2~2) for the "all" and "preinstall" targets.

The commit cleaned up the Makefile generator to use the same logic for
the "all" target in the top-level directory as for subdirectories.  It
exposed a long-existing bug that caused the "all" target in a
subdirectory to include the "all" targets from sub-subdirectories even
if they are marked `EXCLUDE_FROM_ALL`.  The `Tests/SubDir` test should
fail but the problem is currently covered up by another bug introduced
by commit dc6888573d (Pass EXCLUDE_FROM_ALL from directory to targets,
2019-01-15, v3.14.0-rc1~83^2) that causes the "all" targets in
`EXCLUDE_FROM_ALL` subdirectories to be empty.

Revert the top-level "all" and "preinstall" targets to the old approach
to prepare to fix the latter bug without exposing the long-existing bug
at the top-level.  Leave the "clean" target in the new approach because
it does not honor `EXCLUDE_FROM_ALL` anyway.

Issue: #19753
This commit is contained in:
Brad King 2019-09-27 13:06:56 -04:00
parent 26a0e200e5
commit 156b56480a

View File

@ -232,6 +232,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
depends.push_back(this->EmptyRuleHackDepends);
}
// Write and empty all:
lg->WriteMakeRule(makefileStream, "The main recursive all target", "all",
depends, no_commands, true);
// Write an empty preinstall:
lg->WriteMakeRule(makefileStream, "The main recursive preinstall target",
"preinstall", depends, no_commands, true);
// Write out the "special" stuff
lg->WriteSpecialTargetsTop(makefileStream);
@ -473,8 +481,13 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
ruleFileStream << "\n\n";
}
// Write directory-level rules for "all".
this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false);
if (!lg->IsRootMakefile()) {
// Write directory-level rules for "all".
this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false);
// Write directory-level rules for "preinstall".
this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
}
// Write directory-level rules for "clean".
{
@ -482,9 +495,6 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
lg->AppendDirectoryCleanCommand(cmds);
this->WriteDirectoryRule2(ruleFileStream, lg, "clean", false, false, cmds);
}
// Write directory-level rules for "preinstall".
this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
}
std::vector<cmGlobalGenerator::GeneratedMakeCommand>
@ -707,6 +717,15 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName, depends, commands, true);
// add the all/all dependency
if (!this->IsExcluded(gtarget)) {
depends.clear();
depends.push_back(localName);
commands.clear();
lg->WriteMakeRule(ruleFileStream, "Include target in all.", "all",
depends, commands, true);
}
// Write the rule.
commands.clear();