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

Method SaveVerificationScript

Source/cmGlobVerificationManager.cxx:18–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include "cmVersion.h"
17
18bool cmGlobVerificationManager::SaveVerificationScript(std::string const& path,
19 cmMessenger* messenger)
20{
21 if (this->Cache.empty()) {
22 return true;
23 }
24
25 std::string scriptFile = cmStrCat(path, "/CMakeFiles");
26 std::string stampFile = scriptFile;
27 cmSystemTools::MakeDirectory(scriptFile);
28 scriptFile += "/VerifyGlobs.cmake";
29 stampFile += "/cmake.verify_globs";
30 cmGeneratedFileStream verifyScriptFile(scriptFile);
31 verifyScriptFile.SetCopyIfDifferent(true);
32 if (!verifyScriptFile) {
33 cmSystemTools::Error("Unable to open verification script file for save. " +
34 scriptFile);
35 cmSystemTools::ReportLastSystemError("");
36 return false;
37 }
38
39 verifyScriptFile << std::boolalpha;
40 verifyScriptFile << "# CMAKE generated file: DO NOT EDIT!\n"
41 << "# Generated by CMake Version "
42 << cmVersion::GetMajorVersion() << "."
43 << cmVersion::GetMinorVersion() << "\n";
44
45 for (auto const& i : this->Cache) {
46 CacheEntryKey k = std::get<0>(i);
47 CacheEntryValue v = std::get<1>(i);
48
49 if (!v.Initialized) {
50 continue;
51 }
52
53 verifyScriptFile << "\n";
54
55 for (auto const& bt : v.Backtraces) {
56 verifyScriptFile << "# " << std::get<0>(bt);
57 messenger->PrintBacktraceTitle(verifyScriptFile, std::get<1>(bt));
58 verifyScriptFile << "\n";
59 }
60
61 k.PrintGlobCommand(verifyScriptFile, "NEW_GLOB");
62 verifyScriptFile << "\n";
63
64 verifyScriptFile << "set(OLD_GLOB\n";
65 for (std::string const& file : v.Files) {
66 verifyScriptFile << " \"" << file << "\"\n";
67 }
68 verifyScriptFile << " )\n";
69
70 verifyScriptFile << "if(NOT \"${NEW_GLOB}\" STREQUAL \"${OLD_GLOB}\")\n"
71 << " message(\"-- GLOB mismatch!\")\n"
72 << " set(NEW_ONLY ${NEW_GLOB})\n"
73 << " set(OLD_ONLY ${OLD_GLOB})\n"
74 << " list(REMOVE_ITEM NEW_ONLY ${OLD_GLOB})\n"
75 << " list(REMOVE_ITEM OLD_ONLY ${NEW_GLOB})\n"

Callers

nothing calls this directly

Calls 8

SetCopyIfDifferentMethod · 0.80
PrintBacktraceTitleMethod · 0.80
PrintGlobCommandMethod · 0.80
CloseMethod · 0.80
c_strMethod · 0.80
cmStrCatFunction · 0.70
ErrorClass · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected