| 
					
				 | 
			
			
				@@ -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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |