summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-11-12 14:51:05 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-11-12 14:51:16 (GMT)
commit5b46bc319435f429e3e616246e5e39b06f0e7fd0 (patch)
tree9cdfdc9b88e2a50270fba541b988442e47794cc7 /Source
parent45f8b10e0c12b3e17315851afd1bcd178225ce6a (diff)
parent9a5418320ea40d61a63fd47e5ac133c3ff780062 (diff)
downloadCMake-5b46bc319435f429e3e616246e5e39b06f0e7fd0.zip
CMake-5b46bc319435f429e3e616246e5e39b06f0e7fd0.tar.gz
CMake-5b46bc319435f429e3e616246e5e39b06f0e7fd0.tar.bz2
Merge topic 'unity-HEADER_FILE_ONLY'
9a5418320e Unity: Don't include sources with HEADER_FILE_ONLY property set Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4023
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileAPICodemodel.cxx1
-rw-r--r--Source/cmGeneratorTarget.cxx19
-rw-r--r--Source/cmGeneratorTarget.h9
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx4
-rw-r--r--Source/cmLocalGenerator.cxx6
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx1
6 files changed, 35 insertions, 5 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index a12b3c9..d7993c7 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1081,6 +1081,7 @@ Json::Value Target::DumpSource(cmGeneratorTarget::SourceAndKind const& sk,
case cmGeneratorTarget::SourceKindModuleDefinition:
case cmGeneratorTarget::SourceKindResx:
case cmGeneratorTarget::SourceKindXaml:
+ case cmGeneratorTarget::SourceKindUnityBatched:
break;
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index dd3fefa..573ad4d 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1563,6 +1563,8 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
kind = SourceKindCustomCommand;
} else if (this->Target->GetType() == cmStateEnums::UTILITY) {
kind = SourceKindExtra;
+ } else if (this->IsSourceFilePartOfUnityBatch(sf->ResolveFullPath())) {
+ kind = SourceKindUnityBatched;
} else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) {
kind = SourceKindHeader;
} else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
@@ -3604,6 +3606,23 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions(
return inserted.first->second;
}
+void cmGeneratorTarget::AddSourceFileToUnityBatch(
+ const std::string& sourceFilename)
+{
+ this->UnityBatchedSourceFiles.insert(sourceFilename);
+}
+
+bool cmGeneratorTarget::IsSourceFilePartOfUnityBatch(
+ const std::string& sourceFilename) const
+{
+ if (!this->GetPropertyAsBool("UNITY_BUILD")) {
+ return false;
+ }
+
+ return this->UnityBatchedSourceFiles.find(sourceFilename) !=
+ this->UnityBatchedSourceFiles.end();
+}
+
void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result,
const std::string& config,
const std::string& language) const
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index f70b969..336c91f 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -11,6 +11,7 @@
#include <set>
#include <string>
#include <unordered_map>
+#include <unordered_set>
#include <utility>
#include <vector>
@@ -99,7 +100,8 @@ public:
SourceKindModuleDefinition,
SourceKindObjectSource,
SourceKindResx,
- SourceKindXaml
+ SourceKindXaml,
+ SourceKindUnityBatched
};
/** A source file paired with a kind (classification). */
@@ -477,6 +479,9 @@ public:
std::string GetPchUseCompileOptions(const std::string& config,
const std::string& language);
+ void AddSourceFileToUnityBatch(const std::string& sourceFilename);
+ bool IsSourceFilePartOfUnityBatch(const std::string& sourceFilename) const;
+
bool IsSystemIncludeDirectory(const std::string& dir,
const std::string& config,
const std::string& language) const;
@@ -902,6 +907,8 @@ private:
mutable std::map<std::string, std::string> PchCreateCompileOptions;
mutable std::map<std::string, std::string> PchUseCompileOptions;
+ std::unordered_set<std::string> UnityBatchedSourceFiles;
+
void ExpandLinkItems(std::string const& prop, std::string const& value,
std::string const& config,
const cmGeneratorTarget* headTarget,
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index df30e7e..cb15039 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1177,7 +1177,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
headerFiles.push_back(xsf);
} else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) {
resourceFiles.push_back(xsf);
- } else if (!sourceFile->GetPropertyAsBool("HEADER_FILE_ONLY")) {
+ } else if (!sourceFile->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+ !gtgt->IsSourceFilePartOfUnityBatch(
+ sourceFile->ResolveFullPath())) {
// Include this file in the build if it has a known language
// and has not been listed as an ignored extension for this
// generator.
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 2697c65..81cd099 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2441,6 +2441,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
std::back_inserter(filtered_sources), [&](cmSourceFile* sf) {
return sf->GetLanguage() == lang &&
!sf->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION") &&
+ !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
!sf->GetProperty("COMPILE_OPTIONS") &&
!sf->GetProperty("COMPILE_DEFINITIONS") &&
!sf->GetProperty("COMPILE_FLAGS") &&
@@ -2474,11 +2475,10 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
cmSourceFile* sf = filtered_sources[begin];
// Only in Visual Studio generator we keep the source files
- // for explicit processing. For the rest the source files will
- // not be included in the project.
+ // for explicit processing.
if (!this->GetGlobalGenerator()->IsMultiConfig() ||
this->GetGlobalGenerator()->IsXcode()) {
- sf->SetProperty("HEADER_FILE_ONLY", "ON");
+ target->AddSourceFileToUnityBatch(sf->ResolveFullPath());
}
sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str());
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index dac86a1..0456ea5 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2160,6 +2160,7 @@ 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: