diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-17 15:02:53 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-18 10:06:49 (GMT) |
commit | 827da1119ef2d0978dd6dbc58aeee803e43b2455 (patch) | |
tree | 273248d765ee0bed6c8e90a1f4ce7bcf1796ee06 /Source/cmGlobalUnixMakefileGenerator3.cxx | |
parent | adc3459707c4c942b547eb57d02a82b8d5085962 (diff) | |
download | CMake-827da1119ef2d0978dd6dbc58aeee803e43b2455.zip CMake-827da1119ef2d0978dd6dbc58aeee803e43b2455.tar.gz CMake-827da1119ef2d0978dd6dbc58aeee803e43b2455.tar.bz2 |
Makefiles: Make build root targets "all", "clean" and "preinstall" recursive
In the "Unix Makefiles" generator, the subdirectory targets "all", "clean" and
"preinstall" in Makefile2 are recursive. In the build root directory,
these targets aren't. Instead they're are added separately and additional
dependencies are added on a per target basis. This is inconsistent and it
complicates per directory commands, like a per directory clean command.
This patch makes the "all", "clean" and "preinstall" targets in Makefile2
in the build root directory recursive, using the same algorithm that is
already used for subdirectories.
Some side effects are:
- Makefile2 gets smaller and simpler
- The main "all", "clean" and "preinstall" targets have recursive dependencies,
instead of flat (depth of 1) ones.
Diffstat (limited to 'Source/cmGlobalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator3.cxx | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 2f3bc76..f640d52 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -232,18 +232,6 @@ 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 an empty clean: - lg->WriteMakeRule(makefileStream, "The main recursive clean target", "clean", - depends, no_commands, true); - // Write out the "special" stuff lg->WriteSpecialTargetsTop(makefileStream); @@ -414,7 +402,7 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( { // Get the relative path to the subdirectory from the top. std::string makeTarget = lg->GetCurrentBinaryDirectory(); - makeTarget += "/"; + makeTarget += '/'; makeTarget += pass; // The directory-level rule should depend on the target-level rules @@ -444,7 +432,7 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( // rules of the subdirectories. for (cmStateSnapshot const& c : lg->GetStateSnapshot().GetChildren()) { std::string subdir = c.GetDirectory().GetCurrentBinary(); - subdir += "/"; + subdir += '/'; subdir += pass; depends.push_back(std::move(subdir)); } @@ -456,9 +444,16 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( } // Write the rule. - std::string doc = "Convenience name for \""; - doc += pass; - doc += "\" pass in the directory."; + std::string doc; + if (lg->IsRootMakefile()) { + doc = "The main recursive \""; + doc += pass; + doc += "\" target."; + } else { + doc = "Recursive \""; + doc += pass; + doc += "\" directory target."; + } std::vector<std::string> no_commands; lg->WriteMakeRule(ruleFileStream, doc.c_str(), makeTarget, depends, no_commands, true); @@ -467,17 +462,19 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2( std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg) { - // Only subdirectories need these rules. - if (lg->IsRootMakefile()) { - return; - } - // Begin the directory-level rules section. - std::string dir = - cmSystemTools::ConvertToOutputPath(lg->MaybeConvertToRelativePath( - lg->GetBinaryDirectory(), lg->GetCurrentBinaryDirectory())); - lg->WriteDivider(ruleFileStream); - ruleFileStream << "# Directory level rules for directory " << dir << "\n\n"; + { + std::string dir = + cmSystemTools::ConvertToOutputPath(lg->MaybeConvertToRelativePath( + lg->GetBinaryDirectory(), lg->GetCurrentBinaryDirectory())); + lg->WriteDivider(ruleFileStream); + if (lg->IsRootMakefile()) { + ruleFileStream << "# Directory level rules for the build root directory"; + } else { + ruleFileStream << "# Directory level rules for directory " << dir; + } + ruleFileStream << "\n\n"; + } // Write directory-level rules for "all". this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false); @@ -709,15 +706,6 @@ 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(); @@ -794,9 +782,6 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( lg->WriteMakeRule(ruleFileStream, "clean rule for target.", makeTargetName, depends, commands, true); commands.clear(); - depends.push_back(makeTargetName); - lg->WriteMakeRule(ruleFileStream, "clean rule for target.", "clean", - depends, commands, true); } } } |