summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator2.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-02-09 16:40:01 (GMT)
committerBrad King <brad.king@kitware.com>2005-02-09 16:40:01 (GMT)
commit4931afd89d7d7fe8d4c56aa9a7d62250945edede (patch)
tree26cbf3de48c7274dc2d5f6ed4cf3d5371daf6414 /Source/cmLocalUnixMakefileGenerator2.cxx
parent5798510cc7a7543f3583e36f7860488f1c7f6a69 (diff)
downloadCMake-4931afd89d7d7fe8d4c56aa9a7d62250945edede.zip
CMake-4931afd89d7d7fe8d4c56aa9a7d62250945edede.tar.gz
CMake-4931afd89d7d7fe8d4c56aa9a7d62250945edede.tar.bz2
ENH: Adding cleaning of custom command outputs during "make clean".
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator2.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.cxx84
1 files changed, 54 insertions, 30 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx
index fda2e0a..1c7e973 100644
--- a/Source/cmLocalUnixMakefileGenerator2.cxx
+++ b/Source/cmLocalUnixMakefileGenerator2.cxx
@@ -46,10 +46,6 @@
// TODO: Add "help" target.
// TODO: Identify remaining relative path violations.
// TODO: Need test for separate executable/library output path.
-// TODO: Add registered files for cleaning:
-// $(GENERATED_QT_FILES) $(GENERATED_FLTK_FILES)
-// What about cleaning custom command outputs?
-
//----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator2::cmLocalUnixMakefileGenerator2()
@@ -706,6 +702,35 @@ cmLocalUnixMakefileGenerator2
preEcho += "...";
this->WriteMakeRule(ruleFileStream, comment, preEcho.c_str(),
cc.GetOutput().c_str(), depends, commands);
+
+ // Write the clean rule for this custom command.
+ std::string cleanTarget = customName;
+ cleanTarget += ".clean";
+ commands.clear();
+ depends.clear();
+ std::vector<std::string> cleanFiles;
+ cleanFiles.push_back(cc.GetOutput().c_str());
+ this->AppendCleanCommand(commands, cleanFiles);
+ this->WriteMakeRule(ruleFileStream,
+ "Clean the output of this custom command.", 0,
+ cleanTarget.c_str(), depends, commands);
+
+ // Check whether to attach the clean rule.
+ bool attach = true;
+ if(const char* clean_no_custom =
+ m_Makefile->GetProperty("CLEAN_NO_CUSTOM"))
+ {
+ if(!cmSystemTools::IsOff(clean_no_custom))
+ {
+ attach = false;
+ }
+ }
+
+ // Attach the clean rule to the directory-level clean rule.
+ if(attach)
+ {
+ this->WriteLocalRule(ruleFileStream, "clean", cleanTarget.c_str());
+ }
}
//----------------------------------------------------------------------------
@@ -1797,23 +1822,17 @@ cmLocalUnixMakefileGenerator2
// Add a command to remove any existing files for this library.
std::vector<std::string> cleanFiles;
- std::string remove = "$(CMAKE_COMMAND) -E remove -f ";
- remove += targetOutPathReal;
- cleanFiles.push_back(targetOutPathReal);
+ cleanFiles.push_back(targetFullPathReal);
if(targetOutPathSO != targetOutPathReal)
{
- remove += " ";
- remove += targetOutPathSO;
- cleanFiles.push_back(targetOutPathSO);
+ cleanFiles.push_back(targetFullPathSO);
}
if(targetOutPath != targetOutPathSO &&
targetOutPath != targetOutPathReal)
{
- remove += " ";
- remove += targetOutPath;
- cleanFiles.push_back(targetOutPath);
+ cleanFiles.push_back(targetFullPath);
}
- commands.push_back(remove);
+ this->AppendCleanCommand(commands, cleanFiles);
// TODO: Pre-build and pre-link rules.
@@ -2008,14 +2027,7 @@ cmLocalUnixMakefileGenerator2
cleanTarget += ".clean";
// Construct the clean command.
- std::string remove = "$(CMAKE_COMMAND) -E remove -f";
- for(std::vector<std::string>::const_iterator f = files.begin();
- f != files.end(); ++f)
- {
- remove += " ";
- remove += *f;
- }
- commands.push_back(remove);
+ this->AppendCleanCommand(commands, files);
// Write the rule.
this->WriteMakeRule(ruleFileStream, 0, 0, cleanTarget.c_str(),
@@ -2110,16 +2122,9 @@ cmLocalUnixMakefileGenerator2
else
{
// Have extra files to clean. Write the action to remove them.
- std::string remove = "$(CMAKE_COMMAND) -E remove -f";
- for(std::vector<std::string>::iterator i = files.begin();
- i != files.end(); ++i)
- {
- remove += " ";
- remove += this->ConvertToRelativeOutputPath(i->c_str());
- }
std::vector<std::string> no_depends;
std::vector<std::string> commands;
- commands.push_back(remove);
+ this->AppendCleanCommand(commands, files);
this->WriteMakeRule(makefileStream,
"Clean extra files in this directory.", 0,
"clean.local", no_depends, commands);
@@ -2720,6 +2725,25 @@ cmLocalUnixMakefileGenerator2
}
//----------------------------------------------------------------------------
+void
+cmLocalUnixMakefileGenerator2
+::AppendCleanCommand(std::vector<std::string>& commands,
+ const std::vector<std::string>& files)
+{
+ if(!files.empty())
+ {
+ std::string remove = "$(CMAKE_COMMAND) -E remove -f";
+ for(std::vector<std::string>::const_iterator f = files.begin();
+ f != files.end(); ++f)
+ {
+ remove += " ";
+ remove += this->ConvertToRelativeOutputPath(f->c_str());
+ }
+ commands.push_back(remove);
+ }
+}
+
+//----------------------------------------------------------------------------
std::string
cmLocalUnixMakefileGenerator2
::GetRecursiveMakeCall(const char* tgt)