summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-10 16:25:12 (GMT)
committerBrad King <brad.king@kitware.com>2021-11-10 18:54:01 (GMT)
commit3017b3e7d4da702c8b1e2dbfb9657b7517e108b8 (patch)
treebf723c015a9e8411e85e3fd056726dc1df01ff3c /Source/cmLocalGenerator.cxx
parent0b56f92576232d82a23ab37c597ef9af84daf9e5 (diff)
downloadCMake-3017b3e7d4da702c8b1e2dbfb9657b7517e108b8.zip
CMake-3017b3e7d4da702c8b1e2dbfb9657b7517e108b8.tar.gz
CMake-3017b3e7d4da702c8b1e2dbfb9657b7517e108b8.tar.bz2
cmLocalGenerator: Simplify unity source copy-if-different logic
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx21
1 files changed, 8 insertions, 13 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 66b49e0..2b5b711 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2813,20 +2813,15 @@ std::string cmLocalGenerator::WriteUnitySource(
cmValue beforeInclude, cmValue afterInclude, std::string filename) const
{
cmValue uniqueIdName = target->GetProperty("UNITY_BUILD_UNIQUE_ID");
- const std::string filename_tmp = cmStrCat(filename, ".tmp");
- {
- cmGeneratedFileStream file(
- filename_tmp, false,
- target->GetGlobalGenerator()->GetMakefileEncoding());
- file << "/* generated by CMake */\n\n";
-
- for (cmSourceFile* sf : sources) {
- RegisterUnitySources(target, sf, filename);
- IncludeFileInUnitySources(file, sf->ResolveFullPath(), beforeInclude,
- afterInclude, uniqueIdName);
- }
+ cmGeneratedFileStream file(
+ filename, false, target->GetGlobalGenerator()->GetMakefileEncoding());
+ file.SetCopyIfDifferent(true);
+ file << "/* generated by CMake */\n\n";
+ for (cmSourceFile* sf : sources) {
+ RegisterUnitySources(target, sf, filename);
+ IncludeFileInUnitySources(file, sf->ResolveFullPath(), beforeInclude,
+ afterInclude, uniqueIdName);
}
- cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
return filename;
}