summaryrefslogtreecommitdiffstats
path: root/Source/cmUnixMakefileGenerator.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-12-07 15:58:06 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-12-07 15:58:06 (GMT)
commit30a56de4b7355d3fa69545af9571105b8cae8eb9 (patch)
tree503f00ad99e6bc1a14e83c756de0c14b13d5d620 /Source/cmUnixMakefileGenerator.cxx
parent728d20302ee99b57bd19b2bd9501500907993913 (diff)
downloadCMake-30a56de4b7355d3fa69545af9571105b8cae8eb9.zip
CMake-30a56de4b7355d3fa69545af9571105b8cae8eb9.tar.gz
CMake-30a56de4b7355d3fa69545af9571105b8cae8eb9.tar.bz2
ENH: add custom commands for targets
Diffstat (limited to 'Source/cmUnixMakefileGenerator.cxx')
-rw-r--r--Source/cmUnixMakefileGenerator.cxx69
1 files changed, 64 insertions, 5 deletions
diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx
index 23a2337..3b53240 100644
--- a/Source/cmUnixMakefileGenerator.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -545,6 +545,36 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
}
+std::string cmUnixMakefileGenerator::CreateTargetRules(const cmTarget &target,
+ const char* targetName)
+{
+ std::string customRuleCode = "";
+ bool initNext = false;
+ for (std::vector<cmCustomCommand>::const_iterator cr =
+ target.GetCustomCommands().begin();
+ cr != target.GetCustomCommands().end(); ++cr)
+ {
+ cmCustomCommand cc(*cr);
+ cc.ExpandVariables(*m_Makefile);
+ if (cc.GetSourceName() == targetName)
+ {
+ if(initNext)
+ {
+ customRuleCode += "\n\t";
+ }
+ else
+ {
+ initNext = true;
+ }
+ std::string command = cmSystemTools::EscapeSpaces(cc.GetCommand().c_str());
+ command = this->ConvertToNativePath(command.c_str());
+ customRuleCode += command + " " + cc.GetArguments();
+ }
+ }
+ return customRuleCode;
+}
+
+
void cmUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
const char* name,
const cmTarget &t)
@@ -566,11 +596,18 @@ void cmUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
linklibs << std::ends;
command2 += linklibs.str();
delete [] linklibs.str();
+ std::string customCommands = this->CreateTargetRules(t, name);
+ const char* cc = 0;
+ if(customCommands.size() > 0)
+ {
+ cc = customCommands.c_str();
+ }
this->OutputMakeRule(fout, "rules for a shared library",
target.c_str(),
depend.c_str(),
command.c_str(),
- command2.c_str());
+ command2.c_str(),
+ cc);
}
void cmUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
@@ -591,17 +628,24 @@ void cmUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
linklibs << std::ends;
command2 += linklibs.str();
delete [] linklibs.str();
+ std::string customCommands = this->CreateTargetRules(t, name);
+ const char* cc = 0;
+ if(customCommands.size() > 0)
+ {
+ cc = customCommands.c_str();
+ }
this->OutputMakeRule(fout, "rules for a shared module library",
target.c_str(),
depend.c_str(),
command.c_str(),
- command2.c_str());
+ command2.c_str(),
+ cc);
}
void cmUnixMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
const char* name,
- const cmTarget &)
+ const cmTarget &t)
{
std::string target = m_LibraryOutputPath + "lib" + std::string(name) + ".a";
std::string depend = "$(";
@@ -618,12 +662,19 @@ void cmUnixMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
command2 += std::string(name) + ".a";
std::string comment = "rule to build static library: ";
comment += name;
+ std::string customCommands = this->CreateTargetRules(t, name);
+ const char* cc = 0;
+ if(customCommands.size() > 0)
+ {
+ cc = customCommands.c_str();
+ }
this->OutputMakeRule(fout,
comment.c_str(),
target.c_str(),
depend.c_str(),
command.c_str(),
- command2.c_str());
+ command2.c_str(),
+ cc);
}
void cmUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
@@ -643,11 +694,19 @@ void cmUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
command += " -o " + m_ExecutableOutputPath + name;
std::string comment = "rule to build executable: ";
comment += name;
+
+ std::string customCommands = this->CreateTargetRules(t, name);
+ const char* cc = 0;
+ if(customCommands.size() > 0)
+ {
+ cc = customCommands.c_str();
+ }
this->OutputMakeRule(fout,
comment.c_str(),
target.c_str(),
depend.c_str(),
- command.c_str());
+ command.c_str(),
+ cc);
}