cmLocalGenerator: ignore scanned sources for unity builds

This commit is contained in:
Ben Boeckel
2024-01-01 11:04:29 -05:00
committed by Brad King
parent 76b5383123
commit 63bbb3768d
4 changed files with 22 additions and 0 deletions
+9
View File
@@ -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);