ENH: Cleaned up generation of symbolic rules. Removed generation of rebuild_cache and similar rules from internal makefiles.

This commit is contained in:
Brad King 2006-02-15 16:35:16 -05:00
parent 38c3145ce1
commit 60cd72d01c
7 changed files with 217 additions and 263 deletions

View File

@ -130,17 +130,10 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
// Write the do not edit header.
lg->WriteDisclaimer(makefileStream);
// Write out the "special" stuff
lg->WriteSpecialTargetsTop(makefileStream);
// Write the main entry point target. This must be the VERY first
// target so that make with no arguments will run it.
// Just depend on the all target to drive the build.
std::vector<std::string> depends;
const char* sym = lg->GetMakefile()->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
depends.push_back(sym);
}
std::vector<std::string> no_commands;
depends.push_back("all");
@ -150,20 +143,19 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
"given to make.",
"default_target",
depends,
no_commands);
no_commands, true);
depends.clear();
if(sym)
{
depends.push_back(sym);
}
// Write and empty all:
lg->WriteMakeRule(makefileStream,
"The main recursive all target", "all",
depends, no_commands);
depends, no_commands, true);
lg->WriteMakeVariables(makefileStream);
// Write out the "special" stuff
lg->WriteSpecialTargetsTop(makefileStream);
// write the target convenience rules
unsigned int i;
@ -396,12 +388,12 @@ cmGlobalUnixMakefileGenerator3
// Write the rule.
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
localName.c_str(), depends, commands);
localName.c_str(), depends, commands, true);
// Write the rule.
commands.clear();
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
makeTargetName.c_str(), all_tgts, commands);
makeTargetName.c_str(), all_tgts, commands, true);
}
// now do the clean targets
@ -450,7 +442,7 @@ cmGlobalUnixMakefileGenerator3
// write the directory clean rule
commands.clear();
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.",
makeTargetName.c_str(), all_tgts, commands);
makeTargetName.c_str(), all_tgts, commands, true);
}
}
@ -526,12 +518,12 @@ cmGlobalUnixMakefileGenerator3
// Write the rule.
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
localName.c_str(), depends, commands);
localName.c_str(), depends, commands, true);
// Write the rule.
commands.clear();
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
makeTargetName.c_str(), all_tgts, commands);
makeTargetName.c_str(), all_tgts, commands, true);
}
// now do the clean targets
@ -580,7 +572,7 @@ cmGlobalUnixMakefileGenerator3
// write the directory clean rule
commands.clear();
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.",
makeTargetName.c_str(), all_tgts, commands);
makeTargetName.c_str(), all_tgts, commands, true);
}
}
@ -601,8 +593,6 @@ cmGlobalUnixMakefileGenerator3
for (i = 0; i < m_LocalGenerators.size(); ++i)
{
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
const char* sym = lg->GetMakefile()->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
// for each target Generate the rule files for each target.
cmTargets& targets = lg->GetMakefile()->GetTargets();
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
@ -630,14 +620,11 @@ cmGlobalUnixMakefileGenerator3
commands.push_back(lg->GetRecursiveMakeCall
("CMakeFiles/Makefile2",t->second.GetName()));
depends.clear();
if(sym)
{
depends.push_back(sym);
}
depends.push_back("cmake_check_build_system");
lg->WriteMakeRule(ruleFileStream,
"Build rule for target.",
t->second.GetName(), depends, commands);
t->second.GetName(), depends, commands,
true);
}
}
}
@ -711,14 +698,9 @@ cmGlobalUnixMakefileGenerator3
// Write the rule.
localName += "/all";
depends.clear();
const char* sym = lg->GetMakefile()->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
depends.push_back(sym);
}
this->AppendGlobalTargetDepends(depends,t->second);
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName.c_str(), depends, commands);
localName.c_str(), depends, commands, true);
// add the all/all dependency
if (!exclude && t->second.IsInAll())
@ -726,8 +708,8 @@ cmGlobalUnixMakefileGenerator3
depends.clear();
depends.push_back(localName);
commands.clear();
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
"all", depends, commands);
lg->WriteMakeRule(ruleFileStream, "Include target in all.",
"all", depends, commands, true);
}
// Write the rule.
@ -735,42 +717,34 @@ cmGlobalUnixMakefileGenerator3
commands.push_back(lg->GetRecursiveMakeCall
("CMakeFiles/Makefile2",localName.c_str()));
depends.clear();
if(sym)
{
depends.push_back(sym);
}
depends.push_back("cmake_check_build_system");
localName = lg->GetRelativeTargetDirectory(t->second);
localName += "/rule";
lg->WriteMakeRule(ruleFileStream,
"Build rule for subdir invocation for target.",
localName.c_str(), depends, commands);
localName.c_str(), depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
commands.clear();
depends.clear();
depends.push_back(localName);
lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
t->second.GetName(), depends, commands);
t->second.GetName(), depends, commands, true);
// add the clean rule
localName = lg->GetRelativeTargetDirectory(t->second);
makeTargetName = localName;
makeTargetName += "/clean";
depends.clear();
if(sym)
{
depends.push_back(sym);
}
commands.clear();
commands.push_back(lg->GetRecursiveMakeCall
(makefileName.c_str(), makeTargetName.c_str()));
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
makeTargetName.c_str(), depends, commands);
makeTargetName.c_str(), depends, commands, true);
commands.clear();
depends.push_back(makeTargetName);
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
"clean", depends, commands);
"clean", depends, commands, true);
}
}
}
@ -934,14 +908,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
}
}
}
const char* sym = lg->GetMakefile()->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
no_depends.push_back(sym);
}
lg->WriteMakeRule(ruleFileStream, "Help Target",
"help:",
no_depends, commands);
no_depends, commands, true);
ruleFileStream << "\n\n";
}

View File

@ -231,7 +231,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
}
this->WriteMakeRule(ruleFileStream,
"target for object file",
lo->first.c_str(), depends, commands);
lo->first.c_str(), depends, commands, false);
}
// add a help target as long as there isn;t a real target named help
@ -279,7 +279,7 @@ void cmLocalUnixMakefileGenerator3
m_Makefile->GetHomeOutputDirectory(),
m_Makefile->GetStartOutputDirectory());
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
localName.c_str(), depends, commands);
localName.c_str(), depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
if(localName != t->second.GetName())
@ -287,7 +287,7 @@ void cmLocalUnixMakefileGenerator3
commands.clear();
depends.push_back(localName);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
t->second.GetName(), depends, commands);
t->second.GetName(), depends, commands, true);
}
}
}
@ -409,7 +409,8 @@ cmLocalUnixMakefileGenerator3
const char* comment,
const char* target,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands)
const std::vector<std::string>& commands,
bool symbolic)
{
// Make sure there is a target.
if(!target || !*target)
@ -447,6 +448,16 @@ cmLocalUnixMakefileGenerator3
space = " ";
}
// Mark the rule as symbolic if requested.
if(symbolic)
{
if(const char* sym =
m_Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE"))
{
os << tgt.c_str() << space << ": " << sym << "\n";
}
}
// Write the rule.
if(depends.empty())
{
@ -557,141 +568,6 @@ cmLocalUnixMakefileGenerator3
<< "# Special targets provided by cmake.\n"
<< "\n";
// Write the main entry point target. This must be the VERY first
// target so that make with no arguments will run it.
{
// Just depend on the all target to drive the build.
std::vector<std::string> depends;
std::vector<std::string> no_commands;
depends.push_back("all");
// Write the rule.
this->WriteMakeRule(makefileStream,
"Default target executed when no arguments are "
"given to make.",
"default_target",
depends,
no_commands);
}
// Write special "test" target to run ctest.
if(m_Makefile->IsOn("CMAKE_TESTING_ENABLED"))
{
std::string ctest;
if(m_Makefile->GetDefinition("CMake_BINARY_DIR"))
{
// We are building CMake itself. Use the ctest that comes with
// this version of CMake instead of the one used to build it.
ctest = m_ExecutableOutputPath;
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
ctest = this->Convert(ctest.c_str(),START_OUTPUT,SHELL);
ctest += " --force-new-ctest-process";
}
else
{
// We are building another project. Use the ctest that comes with
// the CMake building it.
ctest = m_Makefile->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
ctest = this->ConvertToOutputForExisting(ctest.c_str());
}
std::vector<std::string> no_depends;
std::vector<std::string> commands;
this->AppendEcho(commands, "Running tests...");
ctest += " $(ARGS)";
commands.push_back(ctest);
this->WriteMakeRule(makefileStream,
"Special rule to drive testing with ctest.",
"test", no_depends, commands);
}
// Write special "install" target to run cmake_install.cmake script.
{
std::vector<std::string> depends;
const char* sym = m_Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
depends.push_back(sym);
}
std::vector<std::string> commands;
std::string cmd;
if(m_Makefile->GetDefinition("CMake_BINARY_DIR"))
{
// We are building CMake itself. We cannot use the original
// executable to install over itself.
cmd = m_ExecutableOutputPath;
cmd += "cmake";
cmd = this->Convert(cmd.c_str(),START_OUTPUT,SHELL);
}
else
{
cmd = "$(CMAKE_COMMAND)";
}
cmd += " -P cmake_install.cmake";
commands.push_back(cmd);
const char* noall =
m_Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
// Drive the build before installing.
depends.push_back("all");
}
this->WriteMakeRule(makefileStream,
"Special rule to run installation script.",
"install", depends, commands);
}
std::vector<std::string> no_depends;
const char* sym = m_Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
no_depends.push_back(sym);
}
// Write special "rebuild_cache" target to re-run cmake.
{
std::vector<std::string> commands;
this->AppendEcho(commands, "Running CMake to regenerate build system...");
commands.push_back(
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
this->WriteMakeRule(makefileStream,
"Special rule to re-run CMake using make.",
"rebuild_cache",
no_depends,
commands);
}
// Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined.
// Otherwise default to the interactive command-line interface.
if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
{
std::vector<std::string> commands;
this->AppendEcho(commands, "Running CMake cache editor...");
commands.push_back(
"$(CMAKE_EDIT_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
this->WriteMakeRule(makefileStream,
"Special rule to re-run CMake cache editor using make.",
"edit_cache",
no_depends,
commands);
}
else
{
std::vector<std::string> commands;
this->AppendEcho(commands,
"Running interactive CMake command-line interface...");
commands.push_back(
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -i");
this->WriteMakeRule(makefileStream,
"Special rule to re-run CMake cache editor using make.",
"edit_cache",
no_depends,
commands);
}
// Write special target to silence make output. This must be after
// the default target in case VERBOSE is set (which changes the
// name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a
@ -699,7 +575,7 @@ cmLocalUnixMakefileGenerator3
// name of this special target. This gives a make-time choice to
// the user.
std::vector<std::string> commands;
no_depends.clear();
std::vector<std::string> no_depends;
commands.clear();
if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
{
@ -718,7 +594,7 @@ cmLocalUnixMakefileGenerator3
"Suppress display of executed commands.",
"$(VERBOSE).SILENT",
no_depends,
commands);
commands, false);
}
// Special target to cleanup operation of make tool.
@ -727,11 +603,11 @@ cmLocalUnixMakefileGenerator3
"Disable implicit rules so canoncical targets will work.",
".SUFFIXES",
depends,
commands);
commands, false);
// Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make.
depends.push_back(".hpux_make_needs_suffix_list");
this->WriteMakeRule(makefileStream, 0,
".SUFFIXES", depends, commands);
".SUFFIXES", depends, commands, false);
}
@ -759,12 +635,6 @@ cmLocalUnixMakefileGenerator3
std::vector<std::string> no_depends;
std::vector<std::string> commands;
commands.push_back(runRule);
const char* sym = m_Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
no_depends.push_back(sym);
}
this->WriteMakeRule(makefileStream,
"Special rule to run CMake to check the build system "
"integrity.\n"
@ -773,7 +643,7 @@ cmLocalUnixMakefileGenerator3
"because they might be regenerated.",
"cmake_check_build_system",
no_depends,
commands);
commands, true);
}
std::vector<std::string> no_commands;
@ -794,11 +664,6 @@ cmLocalUnixMakefileGenerator3
{
// The helper target depends on the real target.
std::vector<std::string> depends;
const char* sym = m_Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
depends.push_back(sym);
}
depends.push_back(realTarget);
// There are no commands.
@ -806,7 +671,7 @@ cmLocalUnixMakefileGenerator3
// Write the rule.
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
helpTarget, depends, no_commands);
helpTarget, depends, no_commands, true);
}
}
@ -1367,21 +1232,144 @@ void cmLocalUnixMakefileGenerator3
{
this->WriteDisclaimer(ruleFileStream);
this->WriteMakeVariables(ruleFileStream);
this->WriteSpecialTargetsTop(ruleFileStream);
// Write the main entry point target. This must be the VERY first
// target so that make with no arguments will run it.
{
// Just depend on the all target to drive the build.
std::vector<std::string> depends;
std::vector<std::string> no_commands;
depends.push_back("all");
// Write the rule.
this->WriteMakeRule(ruleFileStream,
"Default target executed when no arguments are "
"given to make.",
"default_target",
depends,
no_commands, true);
}
// Write special "test" target to run ctest.
if(m_Makefile->IsOn("CMAKE_TESTING_ENABLED"))
{
std::string ctest;
if(m_Makefile->GetDefinition("CMake_BINARY_DIR"))
{
// We are building CMake itself. Use the ctest that comes with
// this version of CMake instead of the one used to build it.
ctest = m_ExecutableOutputPath;
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
ctest = this->Convert(ctest.c_str(),START_OUTPUT,SHELL);
ctest += " --force-new-ctest-process";
}
else
{
// We are building another project. Use the ctest that comes with
// the CMake building it.
ctest = m_Makefile->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
ctest = this->ConvertToOutputForExisting(ctest.c_str());
}
std::vector<std::string> no_depends;
std::vector<std::string> commands;
this->AppendEcho(commands, "Running tests...");
ctest += " $(ARGS)";
commands.push_back(ctest);
this->WriteMakeRule(ruleFileStream,
"Special rule to drive testing with ctest.",
"test", no_depends, commands, true);
}
// Write special "install" target to run cmake_install.cmake script.
{
std::vector<std::string> depends;
std::vector<std::string> commands;
std::string cmd;
if(m_Makefile->GetDefinition("CMake_BINARY_DIR"))
{
// We are building CMake itself. We cannot use the original
// executable to install over itself.
cmd = m_ExecutableOutputPath;
cmd += "cmake";
cmd = this->Convert(cmd.c_str(),START_OUTPUT,SHELL);
}
else
{
cmd = "$(CMAKE_COMMAND)";
}
cmd += " -P cmake_install.cmake";
commands.push_back(cmd);
const char* noall =
m_Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
// Drive the build before installing.
depends.push_back("all");
}
this->WriteMakeRule(ruleFileStream,
"Special rule to run installation script.",
"install", depends, commands, true);
}
// Write special "rebuild_cache" target to re-run cmake.
{
std::vector<std::string> no_depends;
std::vector<std::string> commands;
this->AppendEcho(commands, "Running CMake to regenerate build system...");
commands.push_back(
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
this->WriteMakeRule(ruleFileStream,
"Special rule to re-run CMake using make.",
"rebuild_cache",
no_depends,
commands, true);
}
// Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined.
// Otherwise default to the interactive command-line interface.
if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
{
std::vector<std::string> no_depends;
std::vector<std::string> commands;
this->AppendEcho(commands, "Running CMake cache editor...");
commands.push_back(
"$(CMAKE_EDIT_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
this->WriteMakeRule(ruleFileStream,
"Special rule to re-run CMake cache editor using make.",
"edit_cache",
no_depends,
commands, true);
}
else
{
std::vector<std::string> no_depends;
std::vector<std::string> commands;
this->AppendEcho(commands,
"Running interactive CMake command-line interface...");
commands.push_back(
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -i");
this->WriteMakeRule(ruleFileStream,
"Special rule to re-run CMake cache editor using make.",
"edit_cache",
no_depends,
commands, true);
}
this->WriteSpecialTargetsTop(ruleFileStream);
std::vector<std::string> depends;
std::vector<std::string> commands;
// Write the all rule.
std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/directorystart";
dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
// if at the top the rule is called all
const char* sym = m_Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
depends.push_back(sym);
}
if (!m_Parent)
{
dir = "all";
@ -1392,7 +1380,8 @@ void cmLocalUnixMakefileGenerator3
this->CreateCDCommand(commands,
m_Makefile->GetHomeOutputDirectory(),
m_Makefile->GetStartOutputDirectory());
this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends, commands);
this->WriteMakeRule(ruleFileStream, "The main all target", "all",
depends, commands, true);
// Write the clean rule.
dir = m_Makefile->GetStartOutputDirectory();
@ -1400,23 +1389,16 @@ void cmLocalUnixMakefileGenerator3
dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
commands.clear();
depends.clear();
if(sym)
{
depends.push_back(sym);
}
commands.push_back
(this->GetRecursiveMakeCall("CMakeFiles/Makefile2",dir.c_str()));
this->CreateCDCommand(commands,
m_Makefile->GetHomeOutputDirectory(),
m_Makefile->GetStartOutputDirectory());
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", depends, commands);
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
depends, commands, true);
// write the depend rule, really a recompute depends rule
depends.clear();
if(sym)
{
depends.push_back(sym);
}
commands.clear();
std::string cmakefileName = "CMakeFiles/Makefile.cmake";
this->Convert(cmakefileName.c_str(),HOME_OUTPUT,
@ -1430,7 +1412,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(runRule);
this->WriteMakeRule(ruleFileStream, "clear depends",
"depend",
depends, commands);
depends, commands, true);
}

View File

@ -72,7 +72,8 @@ public:
const char* comment,
const char* target,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands);
const std::vector<std::string>& commands,
bool symbolic);
// write the main variables used by the makefiles
void WriteMakeVariables(std::ostream& makefileStream);

View File

@ -34,7 +34,10 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
// write in rules for object files
this->WriteCommonCodeRules();
// Write the dependency generation rule.
this->WriteTargetDependRules();
// write the link rules
this->WriteExecutableRule();
@ -53,9 +56,6 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
//----------------------------------------------------------------------------
void cmMakefileExecutableTargetGenerator::WriteExecutableRule()
{
// Write the dependency generation rule.
this->WriteTargetDependRules();
std::vector<std::string> commands;
std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
@ -296,7 +296,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule()
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream,
0,
targetFullPathReal.c_str(),
depends, commands);
depends, commands, false);
// The symlink name for the target should depend on the real target
// so if the target version changes it rebuilds and recreates the
@ -308,7 +308,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule()
depends.push_back(targetFullPathReal.c_str());
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
targetFullPath.c_str(),
depends, commands);
depends, commands, false);
}
// Write convenience targets.

View File

@ -35,6 +35,9 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
// write in rules for object files
this->WriteCommonCodeRules();
// Write the dependency generation rule.
this->WriteTargetDependRules();
// write the link rules
// Write the rule for this target type.
switch(this->Target->GetType())
@ -138,9 +141,6 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules()
void cmMakefileLibraryTargetGenerator::WriteLibraryRules
(const char* linkRuleVar, const char* extraFlags)
{
// Write the dependency generation rule.
this->WriteTargetDependRules();
// TODO: Merge the methods that call this method to avoid
// code duplication.
std::vector<std::string> commands;
@ -351,7 +351,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Write the build rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
targetFullPathReal.c_str(), depends, commands);
targetFullPathReal.c_str(),
depends, commands, false);
// The symlink names for the target should depend on the real target
// so if the target version changes it rebuilds and recreates the
@ -362,7 +363,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
commands.clear();
depends.push_back(targetFullPathReal.c_str());
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
targetFullPathSO.c_str(), depends, commands);
targetFullPathSO.c_str(),
depends, commands, false);
}
if(targetFullPath != targetFullPathSO)
{
@ -370,7 +372,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
commands.clear();
depends.push_back(targetFullPathSO.c_str());
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
targetFullPath.c_str(), depends, commands);
targetFullPath.c_str(),
depends, commands, false);
}
// Write convenience targets.

View File

@ -32,7 +32,7 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator()
{
this->BuildFileStream = 0;
this->InfoFileStream = 0;
this->FlagFileStream = 0;
this->FlagFileStream = 0;
}
cmMakefileTargetGenerator *
@ -398,11 +398,13 @@ cmMakefileTargetGenerator
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
depMark += "/depend.make.mark";
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
depMark.c_str(), depends, no_commands);
depMark.c_str(),
depends, no_commands, false);
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
relativeObj.c_str(), depends, commands);
relativeObj.c_str(),
depends, commands, false);
// If the language needs provides-requires mode, create the
// corresponding targets.
@ -412,7 +414,7 @@ cmMakefileTargetGenerator
// always provide an empty requires target
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
objectRequires.c_str(), p_depends,
no_commands);
no_commands, true);
// write a build rule to recursively build what this obj provides
std::string objectProvides = relativeObj;
@ -429,13 +431,14 @@ cmMakefileTargetGenerator
p_depends.push_back(objectRequires);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
objectProvides.c_str(), p_depends,
r_commands);
r_commands, true);
// write the provides.build rule dependency on the obj file
p_depends.clear();
p_depends.push_back(relativeObj);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
temp.c_str(), p_depends, no_commands);
temp.c_str(), p_depends, no_commands,
true);
}
//----------------------------------------------------------------------------
@ -463,18 +466,14 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
depTarget.c_str(), depends, no_commands);
depTarget.c_str(),
depends, no_commands, true);
}
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::WriteTargetCleanRules()
{
std::vector<std::string> depends;
const char* sym = this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
depends.push_back(sym);
}
std::vector<std::string> commands;
// Construct the clean target name.
@ -490,7 +489,8 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
cleanTarget.c_str(), depends, commands);
cleanTarget.c_str(),
depends, commands, true);
}
@ -527,7 +527,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
depends.push_back(depMark);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
depTarget.c_str(), depends, commands);
depTarget.c_str(),
depends, commands, true);
depends.clear();
// Write the dependency generation rule.
@ -558,7 +559,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
depMark.c_str(), depends, commands);
depMark.c_str(),
depends, commands, false);
}
//----------------------------------------------------------------------------
@ -632,7 +634,8 @@ void cmMakefileTargetGenerator
comment = cc.GetComment();
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment,
cc.GetOutput(), depends, commands);
cc.GetOutput(), depends, commands,
false);
}
//----------------------------------------------------------------------------

View File

@ -38,11 +38,6 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
// Collect the commands and dependencies.
std::vector<std::string> commands;
std::vector<std::string> depends;
const char* sym = this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
depends.push_back(sym);
}
// Utility targets store their rules in pre- and post-build commands.
this->LocalGenerator->AppendCustomDepends
@ -65,7 +60,8 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
this->Target->GetName(), depends, commands);
this->Target->GetName(),
depends, commands, true);
// Write convenience targets.
std::string dir = this->Makefile->GetStartOutputDirectory();