From 81f6e86f12721da4eb9d0d0b4de290a7ef8f55e2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 Dec 2007 11:50:14 -0500 Subject: [PATCH] ENH: Add per-language clean rule generation to cmake_clean.cmake files to include cmake_clean_.cmake files generated by dependency scanning. Add Fortran module file and timestamp cleaning rules. --- Source/cmDependsFortran.cxx | 21 +++++++++++++++++++++ Source/cmLocalUnixMakefileGenerator3.cxx | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index c47e09dd0..ec4ae2a2a 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -219,6 +219,27 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, { fiStream << " " << *i << "\n"; } + + // Create a script to clean the modules. + if(!provides.empty()) + { + std::string fcName = this->TargetDirectory; + fcName += "/cmake_clean_Fortran.cmake"; + cmGeneratedFileStream fcStream(fcName.c_str()); + fcStream << "# Remove fortran modules provided by this target.\n"; + fcStream << "FILE(REMOVE\n"; + for(std::set::const_iterator i = provides.begin(); + i != provides.end(); ++i) + { + std::string mod_upper = cmSystemTools::UpperCase(*i); + std::string mod_lower = *i; + fcStream << " \"" << mod_lower << ".mod\"" + << " \"" << mod_lower << ".mod.stamp\"" + << " \"" << mod_upper << ".mod\"" + << " \"" << mod_upper << ".mod.stamp\"\n"; + } + fcStream << " )\n"; + } return true; } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 3ceeccc14..8838b4247 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1048,6 +1048,26 @@ cmLocalUnixMakefileGenerator3 } fout << ")\n"; 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) + { + fout << " " << *l; + } + fout << ")\n" + << " INCLUDE(" << this->GetTargetDirectory(target) + << "/cmake_clean_${lang}.cmake OPTIONAL)\n" + << "ENDFOREACH(lang)\n"; + } } }