diff options
author | Brad King <brad.king@kitware.com> | 2013-02-15 18:13:14 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-02-15 18:13:14 (GMT) |
commit | 5698d9b86549d1252d5748e818dec1530c7a4296 (patch) | |
tree | 4419e213f38961f6445758b6ab6246fe4f47fb6f /Source/cmake.cxx | |
parent | e85f1c28d4e709bf468cd1d146f71d528f408582 (diff) | |
parent | 2dc17f88dd2de900154f153f521b803ec9b7c377 (diff) | |
download | CMake-5698d9b86549d1252d5748e818dec1530c7a4296.zip CMake-5698d9b86549d1252d5748e818dec1530c7a4296.tar.gz CMake-5698d9b86549d1252d5748e818dec1530c7a4296.tar.bz2 |
Merge topic 'vs-atomic-generated-stamp'
2dc17f8 VS: Replace generation timestamp file atomically
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 036440a..d44a36b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -4033,10 +4033,18 @@ static bool cmakeCheckStampFile(const char* stampName) } // The build system is up to date. The stamp file has been removed - // by the VS IDE due to a "rebuild" request. Just restore it. - std::ofstream stamp(stampName); + // by the VS IDE due to a "rebuild" request. Restore it atomically. + cmOStringStream stampTempStream; + stampTempStream << stampName << ".tmp" << cmSystemTools::RandomSeed(); + std::string stampTempString = stampTempStream.str(); + const char* stampTemp = stampTempString.c_str(); + { + // TODO: Teach cmGeneratedFileStream to use a random temp file (with + // multiple tries in unlikely case of conflict) and use that here. + std::ofstream stamp(stampTemp); stamp << "# CMake generation timestamp file this directory.\n"; - if(stamp) + } + if(cmSystemTools::RenameFile(stampTemp, stampName)) { // Notify the user why CMake is not re-running. It is safe to // just print to stdout here because this code is only reachable @@ -4047,6 +4055,7 @@ static bool cmakeCheckStampFile(const char* stampName) } else { + cmSystemTools::RemoveFile(stampTemp); cmSystemTools::Error("Cannot restore timestamp ", stampName); return false; } |