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

View File

@ -231,7 +231,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
} }
this->WriteMakeRule(ruleFileStream, this->WriteMakeRule(ruleFileStream,
"target for object file", "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 // 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->GetHomeOutputDirectory(),
m_Makefile->GetStartOutputDirectory()); m_Makefile->GetStartOutputDirectory());
this->WriteMakeRule(ruleFileStream, "Convenience name for target.", 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). // Add a target with the canonical name (no prefix, suffix or path).
if(localName != t->second.GetName()) if(localName != t->second.GetName())
@ -287,7 +287,7 @@ void cmLocalUnixMakefileGenerator3
commands.clear(); commands.clear();
depends.push_back(localName); depends.push_back(localName);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.", 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* comment,
const char* target, const char* target,
const std::vector<std::string>& depends, 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. // Make sure there is a target.
if(!target || !*target) if(!target || !*target)
@ -447,6 +448,16 @@ cmLocalUnixMakefileGenerator3
space = " "; 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. // Write the rule.
if(depends.empty()) if(depends.empty())
{ {
@ -557,141 +568,6 @@ cmLocalUnixMakefileGenerator3
<< "# Special targets provided by cmake.\n" << "# Special targets provided by cmake.\n"
<< "\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 // Write special target to silence make output. This must be after
// the default target in case VERBOSE is set (which changes the // the default target in case VERBOSE is set (which changes the
// name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a // 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 // name of this special target. This gives a make-time choice to
// the user. // the user.
std::vector<std::string> commands; std::vector<std::string> commands;
no_depends.clear(); std::vector<std::string> no_depends;
commands.clear(); commands.clear();
if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
{ {
@ -718,7 +594,7 @@ cmLocalUnixMakefileGenerator3
"Suppress display of executed commands.", "Suppress display of executed commands.",
"$(VERBOSE).SILENT", "$(VERBOSE).SILENT",
no_depends, no_depends,
commands); commands, false);
} }
// Special target to cleanup operation of make tool. // Special target to cleanup operation of make tool.
@ -727,11 +603,11 @@ cmLocalUnixMakefileGenerator3
"Disable implicit rules so canoncical targets will work.", "Disable implicit rules so canoncical targets will work.",
".SUFFIXES", ".SUFFIXES",
depends, depends,
commands); commands, false);
// Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make. // Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make.
depends.push_back(".hpux_make_needs_suffix_list"); depends.push_back(".hpux_make_needs_suffix_list");
this->WriteMakeRule(makefileStream, 0, 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> no_depends;
std::vector<std::string> commands; std::vector<std::string> commands;
commands.push_back(runRule); commands.push_back(runRule);
const char* sym = m_Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE");
if(sym)
{
no_depends.push_back(sym);
}
this->WriteMakeRule(makefileStream, this->WriteMakeRule(makefileStream,
"Special rule to run CMake to check the build system " "Special rule to run CMake to check the build system "
"integrity.\n" "integrity.\n"
@ -773,7 +643,7 @@ cmLocalUnixMakefileGenerator3
"because they might be regenerated.", "because they might be regenerated.",
"cmake_check_build_system", "cmake_check_build_system",
no_depends, no_depends,
commands); commands, true);
} }
std::vector<std::string> no_commands; std::vector<std::string> no_commands;
@ -794,11 +664,6 @@ cmLocalUnixMakefileGenerator3
{ {
// The helper target depends on the real target. // The helper target depends on the real target.
std::vector<std::string> depends; 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); depends.push_back(realTarget);
// There are no commands. // There are no commands.
@ -806,7 +671,7 @@ cmLocalUnixMakefileGenerator3
// Write the rule. // Write the rule.
this->WriteMakeRule(ruleFileStream, "Convenience name for target.", 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->WriteDisclaimer(ruleFileStream);
this->WriteMakeVariables(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> depends;
std::vector<std::string> commands; 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. // Write the all rule.
std::string dir = m_Makefile->GetStartOutputDirectory(); std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/directorystart"; dir += "/directorystart";
dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE); dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
// if at the top the rule is called all // 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) if (!m_Parent)
{ {
dir = "all"; dir = "all";
@ -1392,7 +1380,8 @@ void cmLocalUnixMakefileGenerator3
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
m_Makefile->GetHomeOutputDirectory(), m_Makefile->GetHomeOutputDirectory(),
m_Makefile->GetStartOutputDirectory()); 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. // Write the clean rule.
dir = m_Makefile->GetStartOutputDirectory(); dir = m_Makefile->GetStartOutputDirectory();
@ -1400,23 +1389,16 @@ void cmLocalUnixMakefileGenerator3
dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE); dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
commands.clear(); commands.clear();
depends.clear(); depends.clear();
if(sym)
{
depends.push_back(sym);
}
commands.push_back commands.push_back
(this->GetRecursiveMakeCall("CMakeFiles/Makefile2",dir.c_str())); (this->GetRecursiveMakeCall("CMakeFiles/Makefile2",dir.c_str()));
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
m_Makefile->GetHomeOutputDirectory(), m_Makefile->GetHomeOutputDirectory(),
m_Makefile->GetStartOutputDirectory()); 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 // write the depend rule, really a recompute depends rule
depends.clear(); depends.clear();
if(sym)
{
depends.push_back(sym);
}
commands.clear(); commands.clear();
std::string cmakefileName = "CMakeFiles/Makefile.cmake"; std::string cmakefileName = "CMakeFiles/Makefile.cmake";
this->Convert(cmakefileName.c_str(),HOME_OUTPUT, this->Convert(cmakefileName.c_str(),HOME_OUTPUT,
@ -1430,7 +1412,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(runRule); commands.push_back(runRule);
this->WriteMakeRule(ruleFileStream, "clear depends", this->WriteMakeRule(ruleFileStream, "clear depends",
"depend", "depend",
depends, commands); depends, commands, true);
} }

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator()
{ {
this->BuildFileStream = 0; this->BuildFileStream = 0;
this->InfoFileStream = 0; this->InfoFileStream = 0;
this->FlagFileStream = 0; this->FlagFileStream = 0;
} }
cmMakefileTargetGenerator * cmMakefileTargetGenerator *
@ -398,11 +398,13 @@ cmMakefileTargetGenerator
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
depMark += "/depend.make.mark"; depMark += "/depend.make.mark";
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
depMark.c_str(), depends, no_commands); depMark.c_str(),
depends, no_commands, false);
// Write the rule. // Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, 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 // If the language needs provides-requires mode, create the
// corresponding targets. // corresponding targets.
@ -412,7 +414,7 @@ cmMakefileTargetGenerator
// always provide an empty requires target // always provide an empty requires target
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
objectRequires.c_str(), p_depends, objectRequires.c_str(), p_depends,
no_commands); no_commands, true);
// write a build rule to recursively build what this obj provides // write a build rule to recursively build what this obj provides
std::string objectProvides = relativeObj; std::string objectProvides = relativeObj;
@ -429,13 +431,14 @@ cmMakefileTargetGenerator
p_depends.push_back(objectRequires); p_depends.push_back(objectRequires);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
objectProvides.c_str(), p_depends, objectProvides.c_str(), p_depends,
r_commands); r_commands, true);
// write the provides.build rule dependency on the obj file // write the provides.build rule dependency on the obj file
p_depends.clear(); p_depends.clear();
p_depends.push_back(relativeObj); p_depends.push_back(relativeObj);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, 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. // Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
depTarget.c_str(), depends, no_commands); depTarget.c_str(),
depends, no_commands, true);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefileTargetGenerator::WriteTargetCleanRules() void cmMakefileTargetGenerator::WriteTargetCleanRules()
{ {
std::vector<std::string> depends; 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; std::vector<std::string> commands;
// Construct the clean target name. // Construct the clean target name.
@ -490,7 +489,8 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
// Write the rule. // Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, 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); depends.push_back(depMark);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
depTarget.c_str(), depends, commands); depTarget.c_str(),
depends, commands, true);
depends.clear(); depends.clear();
// Write the dependency generation rule. // Write the dependency generation rule.
@ -558,7 +559,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// Write the rule. // Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, 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(); comment = cc.GetComment();
} }
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment, 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. // Collect the commands and dependencies.
std::vector<std::string> commands; std::vector<std::string> commands;
std::vector<std::string> depends; 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. // Utility targets store their rules in pre- and post-build commands.
this->LocalGenerator->AppendCustomDepends this->LocalGenerator->AppendCustomDepends
@ -65,7 +60,8 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
// Write the rule. // Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
this->Target->GetName(), depends, commands); this->Target->GetName(),
depends, commands, true);
// Write convenience targets. // Write convenience targets.
std::string dir = this->Makefile->GetStartOutputDirectory(); std::string dir = this->Makefile->GetStartOutputDirectory();