From dba4962b868c3baa7886dcd3f8b597e971a479a2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Oct 2013 09:52:37 -0400 Subject: Makefile: Always create clean target command Borland Make complains if the phony clean target has no rule to build it. If there are no files to clean, generate and run an empty clean script. --- Source/cmLocalUnixMakefileGenerator3.cxx | 74 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2443583..dc401dc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1158,27 +1158,25 @@ cmLocalUnixMakefileGenerator3 const std::vector& files, cmTarget& target, const char* filename) { + std::string cleanfile = this->Makefile->GetCurrentOutputDirectory(); + cleanfile += "/"; + cleanfile += this->GetTargetDirectory(target); + cleanfile += "/cmake_clean"; + if(filename) + { + cleanfile += "_"; + cleanfile += filename; + } + cleanfile += ".cmake"; + std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); + std::ofstream fout(cleanfilePath.c_str()); + if(!fout) + { + cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); + } if(!files.empty()) { - std::string cleanfile = this->Makefile->GetCurrentOutputDirectory(); - cleanfile += "/"; - cleanfile += this->GetTargetDirectory(target); - cleanfile += "/cmake_clean"; - if(filename) - { - cleanfile += "_"; - cleanfile += filename; - } - cleanfile += ".cmake"; - std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); - std::ofstream fout(cleanfilePath.c_str()); - if(!fout) - { - cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); - } fout << "file(REMOVE_RECURSE\n"; - std::string remove = "$(CMAKE_COMMAND) -P "; - remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL); for(std::vector::const_iterator f = files.begin(); f != files.end(); ++f) { @@ -1186,27 +1184,29 @@ cmLocalUnixMakefileGenerator3 fout << " " << this->EscapeForCMake(fc.c_str()) << "\n"; } fout << ")\n"; - commands.push_back(remove); - - // For the main clean rule add per-language cleaning. - if(!filename) + } + std::string remove = "$(CMAKE_COMMAND) -P "; + remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL); + commands.push_back(remove); + + // For the main clean rule add per-language cleaning. + if(!filename) + { + // Get the set of source languages in the target. + std::set languages; + target.GetLanguages(languages); + fout << "\n" + << "# Per-language clean rules from dependency scanning.\n" + << "foreach(lang"; + for(std::set::const_iterator l = languages.begin(); + l != languages.end(); ++l) { - // Get the set of source languages in the target. - std::set languages; - target.GetLanguages(languages); - fout << "\n" - << "# Per-language clean rules from dependency scanning.\n" - << "foreach(lang"; - for(std::set::const_iterator l = languages.begin(); - l != languages.end(); ++l) - { - fout << " " << *l; - } - fout << ")\n" - << " include(" << this->GetTargetDirectory(target) - << "/cmake_clean_${lang}.cmake OPTIONAL)\n" - << "endforeach()\n"; + fout << " " << *l; } + fout << ")\n" + << " include(" << this->GetTargetDirectory(target) + << "/cmake_clean_${lang}.cmake OPTIONAL)\n" + << "endforeach()\n"; } } -- cgit v0.12