diff options
author | Brad King <brad.king@kitware.com> | 2019-11-26 13:54:54 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-11-26 13:55:09 (GMT) |
commit | 7525f0ec6c87576a938b64d52e88e5b319f4a319 (patch) | |
tree | 204e7a2cec1d2ec5be95e97791446fc1aa8e7d16 | |
parent | bb3d82232d06e553dedd430e6d7a1d0d917108dd (diff) | |
parent | 43ffd2c35caf1df37e915460c05da04b583577c4 (diff) | |
download | CMake-7525f0ec6c87576a938b64d52e88e5b319f4a319.zip CMake-7525f0ec6c87576a938b64d52e88e5b319f4a319.tar.gz CMake-7525f0ec6c87576a938b64d52e88e5b319f4a319.tar.bz2 |
Merge topic 'unity-no-duplicate-path'
43ffd2c35c Unity: No repeated path for internal generated unity files
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4077
-rw-r--r-- | Source/cmLocalGenerator.cxx | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c43876c..a57c40b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3147,6 +3147,22 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( } } + // Ensure that for the CMakeFiles/<target>.dir/generated_source_file + // we don't end up having: + // CMakeFiles/<target>.dir/CMakeFiles/<target>.dir/generated_source_file.obj + const char* unitySourceFile = source.GetProperty("UNITY_SOURCE_FILE"); + const char* pchExtension = source.GetProperty("PCH_EXTENSION"); + if (unitySourceFile || pchExtension) { + if (pchExtension) { + customOutputExtension = pchExtension; + } + + cmsys::RegularExpression var("(CMakeFiles/[^/]+.dir/)"); + if (var.find(objectName)) { + objectName.erase(var.start(), var.end() - var.start()); + } + } + // Replace the original source file extension with the object file // extension. bool keptSourceExtension = true; @@ -3163,19 +3179,6 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( } } - const char* pchExtension = source.GetProperty("PCH_EXTENSION"); - if (pchExtension) { - customOutputExtension = pchExtension; - - // Make sure that for the CMakeFiles/<target>.dir/cmake_pch.h|xx.c|xx - // source file, we don't end up having - // CMakeFiles/<target>.dir/CMakeFiles/<target>.dir/cmake_pch.h|xx.pch - cmsys::RegularExpression var("(CMakeFiles/[^/]+.dir/)"); - while (var.find(objectName)) { - objectName.erase(var.start(), var.end() - var.start()); - } - } - // Remove the source extension if it is to be replaced. if (replaceExt || customOutputExtension) { keptSourceExtension = false; |