MCPcopy Index your code
hub / github.com/Kitware/CMake / AppendCleanCommand

Method AppendCleanCommand

Source/cmLocalUnixMakefileGenerator3.cxx:1138–1186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1136}
1137
1138void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
1139 std::vector<std::string>& commands, std::set<std::string> const& files,
1140 cmGeneratorTarget* target, char const* filename)
1141{
1142 std::string cleanfile =
1143 cmStrCat(target->GetSupportDirectory(), "/cmake_clean");
1144 if (filename) {
1145 cleanfile += "_";
1146 cleanfile += filename;
1147 }
1148 cleanfile += ".cmake";
1149 cmsys::ofstream fout(cleanfile.c_str());
1150 if (!fout) {
1151 cmSystemTools::Error("Could not create " + cleanfile);
1152 }
1153 if (!files.empty()) {
1154 fout << "file(REMOVE_RECURSE\n";
1155 for (std::string const& file : files) {
1156 std::string fc = this->MaybeRelativeToCurBinDir(file);
1157 fout << " " << cmOutputConverter::EscapeForCMake(fc) << '\n';
1158 }
1159 fout << ")\n";
1160 }
1161 {
1162 std::string remove = cmStrCat(
1163 "$(CMAKE_COMMAND) -P ",
1164 this->ConvertToOutputFormat(this->MaybeRelativeToCurBinDir(cleanfile),
1165 cmOutputConverter::SHELL));
1166 commands.push_back(std::move(remove));
1167 }
1168
1169 // For the main clean rule add per-language cleaning.
1170 if (!filename) {
1171 // Get the set of source languages in the target.
1172 std::set<std::string> languages;
1173 target->GetLanguages(
1174 languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
1175 auto langFileDir = cmSystemTools::GetFilenamePath(
1176 this->MaybeRelativeToCurBinDir(cleanfile));
1177 /* clang-format off */
1178 fout << "\n"
1179 "# Per-language clean rules from dependency scanning.\n"
1180 "foreach(lang " << cmJoin(languages, " ") << ")\n"
1181 " include(" << langFileDir
1182 << "/cmake_clean_${lang}.cmake OPTIONAL)\n"
1183 "endforeach()\n";
1184 /* clang-format on */
1185 }
1186}
1187
1188void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand(
1189 std::vector<std::string>& commands)

Callers 2

WriteTargetCleanRulesMethod · 0.80
WriteLibraryRulesMethod · 0.80

Calls 11

moveFunction · 0.85
GetSupportDirectoryMethod · 0.80
c_strMethod · 0.80
push_backMethod · 0.80
cmStrCatFunction · 0.70
ErrorClass · 0.70
cmJoinFunction · 0.70
emptyMethod · 0.45
ConvertToOutputFormatMethod · 0.45
GetLanguagesMethod · 0.45

Tested by

no test coverage detected