summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2024-01-01 16:04:29 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-05 19:21:27 (GMT)
commit63bbb3768d3cf87459b6b66effa8726f38cc745a (patch)
tree55bcf85e8ae41bedf013e2211c64c3f03544e653 /Source/cmLocalGenerator.cxx
parent76b5383123daa4249c9cfffdc93727713dfad29f (diff)
downloadCMake-63bbb3768d3cf87459b6b66effa8726f38cc745a.zip
CMake-63bbb3768d3cf87459b6b66effa8726f38cc745a.tar.gz
CMake-63bbb3768d3cf87459b6b66effa8726f38cc745a.tar.bz2
cmLocalGenerator: ignore scanned sources for unity builds
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 168cd41..7337ea2 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3134,6 +3134,15 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources, configs[ci]);
for (cmSourceFile* sf : sources) {
+ // Files which need C++ scanning cannot participate in unity builds as
+ // there is a single place in TUs that may perform module-dependency bits
+ // and a unity source cannot `#include` them in-order and represent a
+ // valid TU.
+ if (sf->GetLanguage() == "CXX"_s &&
+ target->NeedDyndepForSource("CXX", configs[ci], sf)) {
+ continue;
+ }
+
auto mi = index.find(sf);
if (mi == index.end()) {
unitySources.emplace_back(sf);