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

Function cmakeCheckStampFile

Source/cmake.cxx:180–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178#endif
179
180bool cmakeCheckStampFile(std::string const& stampName)
181{
182 // The stamp file does not exist. Use the stamp dependencies to
183 // determine whether it is really out of date. This works in
184 // conjunction with cmLocalVisualStudio7Generator to avoid
185 // repeatedly re-running CMake when the user rebuilds the entire
186 // solution.
187 std::string stampDepends = cmStrCat(stampName, ".depend");
188#if defined(_WIN32) || defined(__CYGWIN__)
189 cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary);
190#else
191 cmsys::ifstream fin(stampDepends.c_str());
192#endif
193 if (!fin) {
194 // The stamp dependencies file cannot be read. Just assume the
195 // build system is really out of date.
196 std::cout << "CMake is re-running because " << stampName
197 << " dependency file is missing.\n";
198 return false;
199 }
200
201 // Compare the stamp dependencies against the dependency file itself.
202 {
203 cmFileTimeCache ftc;
204 std::string dep;
205 while (cmSystemTools::GetLineFromStream(fin, dep)) {
206 int result;
207 if (!dep.empty() && dep[0] != '#' &&
208 (!ftc.Compare(stampDepends, dep, &result) || result < 0)) {
209 // The stamp depends file is older than this dependency. The
210 // build system is really out of date.
211 /* clang-format off */
212 std::cout << "CMake is re-running because " << stampName
213 << " is out-of-date.\n"
214 " the file '" << dep << "'\n"
215 " is newer than '" << stampDepends << "'\n"
216 " result='" << result << "'\n";
217 /* clang-format on */
218 return false;
219 }
220 }
221 }
222
223 // The build system is up to date. The stamp file has been removed
224 // by the VS IDE due to a "rebuild" request. Restore it atomically.
225 std::ostringstream stampTempStream;
226 stampTempStream << stampName << ".tmp" << cmSystemTools::RandomNumber();
227 std::string stampTemp = stampTempStream.str();
228 {
229 // TODO: Teach cmGeneratedFileStream to use a random temp file (with
230 // multiple tries in unlikely case of conflict) and use that here.
231 cmsys::ofstream stamp(stampTemp.c_str());
232 stamp << "# CMake generation timestamp file for this directory.\n";
233 }
234 std::string err;
235 if (cmSystemTools::RenameFile(stampTemp, stampName,
236 cmSystemTools::Replace::Yes, &err) ==
237 cmSystemTools::RenameResult::Success) {

Callers 2

cmakeCheckStampListFunction · 0.85
RunMethod · 0.85

Calls 6

c_strMethod · 0.80
strMethod · 0.80
cmStrCatFunction · 0.70
ErrorClass · 0.70
emptyMethod · 0.45
CompareMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…