diff options
author | Brad King <brad.king@kitware.com> | 2019-12-09 15:16:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-12-09 15:16:31 (GMT) |
commit | bde1bc73869d426523169996ab0eae3cdbf92f78 (patch) | |
tree | 17cf167e187556b7fa985d95e562ed23009710ec /Source | |
parent | 63c9a71eeb73e30ebeff00eb235ca380661e636c (diff) | |
parent | fc9913075213e7636add2a811d41b6f3a7c37374 (diff) | |
download | CMake-bde1bc73869d426523169996ab0eae3cdbf92f78.zip CMake-bde1bc73869d426523169996ab0eae3cdbf92f78.tar.gz CMake-bde1bc73869d426523169996ab0eae3cdbf92f78.tar.bz2 |
Merge topic 'unity-object-libraries'
fc99130752 Merge branch 'backport-unity-object-libraries' into unity-object-libraries
fa93b4a59b Unity: Proper handling of object libraries
5ae07e7166 Unity: Generic source file handling for all generators
f742f7ac1f Unity/PCH: Skip more target types when adding automatic sources
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4110
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 2 |
3 files changed, 16 insertions, 8 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8dfc0ce..0e782f2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1566,13 +1566,24 @@ bool cmGlobalGenerator::AddAutomaticSources() for (cmLocalGenerator* lg : this->LocalGenerators) { lg->CreateEvaluationFileOutputs(); for (const auto& gt : lg->GetGeneratorTargets()) { - if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY || + gt->GetType() == cmStateEnums::UTILITY || + gt->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } lg->AddUnityBuild(gt.get()); lg->AddPchDependencies(gt.get()); } } + // The above transformations may have changed the classification of sources. + // Clear the source list and classification cache (KindedSources) of all + // targets so that it will be recomputed correctly by the generators later + // now that the above transformations are done for all targets. + for (cmLocalGenerator* lg : this->LocalGenerators) { + for (const auto& gt : lg->GetGeneratorTargets()) { + gt->ClearSourcesCache(); + } + } return true; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index fa997f4..c58603f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2393,6 +2393,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) } const std::string buildType = cmSystemTools::UpperCase(config); + // FIXME: Refactor collection of sources to not evaluate object libraries. std::vector<cmSourceFile*> sources; target->GetSourceFiles(sources, buildType); @@ -2565,6 +2566,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", target->GetName(), ".dir/Unity/"); + // FIXME: Refactor collection of sources to not evaluate object libraries. std::vector<cmSourceFile*> sources; target->GetSourceFiles(sources, buildType); @@ -2614,12 +2616,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) for (; begin != end; ++begin) { cmSourceFile* sf = filtered_sources[begin]; - // Only in Visual Studio generator we keep the source files - // for explicit processing. - if (!this->GetGlobalGenerator()->IsMultiConfig() || - this->GetGlobalGenerator()->IsXcode()) { - target->AddSourceFileToUnityBatch(sf->ResolveFullPath()); - } + target->AddSourceFileToUnityBatch(sf->ResolveFullPath()); sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str()); if (beforeInclude) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5ffa576..8fc40a79 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2160,7 +2160,6 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) this->WriteExtraSource(e1, si.Source); break; case cmGeneratorTarget::SourceKindHeader: - case cmGeneratorTarget::SourceKindUnityBatched: this->WriteHeaderSource(e1, si.Source); break; case cmGeneratorTarget::SourceKindIDL: @@ -2172,6 +2171,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) case cmGeneratorTarget::SourceKindModuleDefinition: tool = "None"; break; + case cmGeneratorTarget::SourceKindUnityBatched: case cmGeneratorTarget::SourceKindObjectSource: { const std::string& lang = si.Source->GetLanguage(); if (lang == "C" || lang == "CXX") { |