summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-05 12:35:29 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-05 12:36:06 (GMT)
commitac4d6d4a9d9b81773e61c643169cb2afe1bab644 (patch)
tree7679958f3ffece7ae00993fa7c26c70d9b6a1dc2 /Source/cmVisualStudio10TargetGenerator.cxx
parentfcba9c3baa00631407f493f97afe7e9cd1b844a7 (diff)
parent7786a05c707dc5ffe9fdf7a6b468f56ed18c9e8a (diff)
downloadCMake-ac4d6d4a9d9b81773e61c643169cb2afe1bab644.zip
CMake-ac4d6d4a9d9b81773e61c643169cb2afe1bab644.tar.gz
CMake-ac4d6d4a9d9b81773e61c643169cb2afe1bab644.tar.bz2
Merge topic 'unity-build'
7786a05c70 Unity build: Add XCode support 1353802af3 Unity build: Add unit tests 8dfeb5d278 Unity build: Add support for Visual Studio generator 7114c141e2 Unity build: Add support for Ninja and Makefile generators Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Stanislav Ershov <digital.stream.of.mind@gmail.com> Acked-by: Evgeniy Dushistov <dushistov@mail.ru> Acked-by: Viktor Kirilov <vik.kirilov@gmail.com> Merge-request: !3611
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 06e1798..29ebe02 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -250,6 +250,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() ==
this->Makefile->GetCurrentBinaryDirectory());
+ this->LocalGenerator->AddUnityBuild(target, "");
this->LocalGenerator->AddPchDependencies(target, "");
}
@@ -2070,6 +2071,17 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) {
return;
}
+
+ const bool haveUnityBuild =
+ this->GeneratorTarget->GetPropertyAsBool("UNITY_BUILD");
+
+ if (haveUnityBuild &&
+ this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VS15) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Element("EnableUnitySupport", "true");
+ }
+
Elem e1(e0, "ItemGroup");
e1.SetHasElements();
@@ -2168,6 +2180,45 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
Elem e2(e1, tool);
this->WriteSource(e2, si.Source);
+
+ bool useNativeUnityBuild = false;
+ if (haveUnityBuild &&
+ this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VS15) {
+ // Magic value taken from cmGlobalVisualStudioVersionedGenerator.cxx
+ static const std::string vs15 = "141";
+ std::string toolset =
+ this->GlobalGenerator->GetPlatformToolsetString();
+ cmSystemTools::ReplaceString(toolset, "v", "");
+
+ if (toolset.empty() ||
+ cmSystemTools::VersionCompareGreaterEq(toolset, vs15)) {
+ useNativeUnityBuild = true;
+ }
+ }
+
+ if (haveUnityBuild && strcmp(tool, "ClCompile") == 0 &&
+ si.Source->GetProperty("UNITY_SOURCE_FILE")) {
+ if (useNativeUnityBuild) {
+ e2.Attribute(
+ "IncludeInUnityFile",
+ si.Source->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION")
+ ? "false"
+ : "true");
+ e2.Attribute("CustomUnityFile", "true");
+
+ std::string unityDir = cmSystemTools::GetFilenamePath(
+ si.Source->GetProperty("UNITY_SOURCE_FILE"));
+ e2.Attribute("UnityFilesDirectory", unityDir);
+ } else {
+ // Visual Studio versions prior to 2017 do not know about unity
+ // builds, thus we exclude the files alredy part of unity sources.
+ if (!si.Source->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION")) {
+ exclude_configs = si.Configs;
+ }
+ }
+ }
+
if (si.Kind == cmGeneratorTarget::SourceKindObjectSource) {
this->OutputSourceSpecificFlags(e2, si.Source);
}