MCPcopy Create free account
hub / github.com/Kitware/CMake / CreateVCProjBuildRule

Method CreateVCProjBuildRule

Source/cmLocalVisualStudio7Generator.cxx:224–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
225{
226 if (this->GlobalGenerator->GlobalSettingIsOn(
227 "CMAKE_SUPPRESS_REGENERATION")) {
228 return nullptr;
229 }
230
231 std::string makefileIn = this->GetCMakeInstance()->GetCMakeListFile(
232 this->GetCurrentSourceDirectory());
233 if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) {
234 if (file->GetCustomCommand()) {
235 return file;
236 }
237 }
238 if (!cmSystemTools::FileExists(makefileIn)) {
239 return nullptr;
240 }
241
242 std::vector<std::string> listFiles = this->Makefile->GetListFiles();
243 cmake* cm = this->GlobalGenerator->GetCMakeInstance();
244 if (cm->DoWriteGlobVerifyTarget()) {
245 listFiles.push_back(cm->GetGlobVerifyStamp());
246 }
247
248 // Sort the list of input files and remove duplicates.
249 std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>());
250 auto new_end = std::unique(listFiles.begin(), listFiles.end());
251 listFiles.erase(new_end, listFiles.end());
252
253 std::string argS = cmStrCat("-S", this->GetSourceDirectory());
254 std::string argB = cmStrCat("-B", this->GetBinaryDirectory());
255 std::string stampName =
256 cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp");
257 cmCustomCommandLines commandLines =
258 cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB,
259 "--check-stamp-file", stampName });
260
261 if (cm->GetIgnoreCompileWarningAsError()) {
262 commandLines[0].emplace_back("--compile-no-warning-as-error");
263 }
264 if (cm->GetIgnoreLinkWarningAsError()) {
265 commandLines[0].emplace_back("--link-no-warning-as-error");
266 }
267 std::string comment = cmStrCat("Building Custom Rule ", makefileIn);
268 auto cc = cm::make_unique<cmCustomCommand>();
269 cc->SetOutputs(stampName);
270 cc->SetMainDependency(makefileIn);
271 cc->SetDepends(listFiles);
272 cc->SetCommandLines(commandLines);
273 cc->SetComment(comment.c_str());
274 cc->SetEscapeOldStyle(false);
275 cc->SetStdPipesUTF8(true);
276 cc->SetUsesTerminal(true);
277 this->AddCustomCommandToOutput(std::move(cc), true);
278 if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) {
279 // Finalize the source file path now since we're adding this after
280 // the generator validated all project-named sources.
281 file->ResolveFullPath();

Callers 4

WriteVCProjFileMethod · 0.95
WriteCustomCommandsMethod · 0.80
WriteGroupsMethod · 0.80
WriteAllSourcesMethod · 0.80

Calls 15

cmMakeSingleCommandLineFunction · 0.85
moveFunction · 0.85
GlobalSettingIsOnMethod · 0.80
GetCMakeListFileMethod · 0.80
GetSourceMethod · 0.80
GetCustomCommandMethod · 0.80
push_backMethod · 0.80
eraseMethod · 0.80
emplace_backMethod · 0.80
SetOutputsMethod · 0.80

Tested by

no test coverage detected