Merge topic 'vs-version-for-unity'

9135954e2f VS: Do not use native unity builds on VS 2017 versions less than 15.8

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4324
This commit is contained in:
Brad King 2020-02-05 13:33:40 +00:00 committed by Kitware Robot
commit 4b062c77b3
3 changed files with 12 additions and 7 deletions

View File

@ -250,6 +250,12 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
}
}
this->SupportsUnityBuilds =
this->Version >= cmGlobalVisualStudioGenerator::VS16 ||
(this->Version == cmGlobalVisualStudioGenerator::VS15 &&
cmSystemTools::PathExists(this->VCTargetsPath +
"/Microsoft.Cpp.Unity.targets"));
if (this->GeneratorToolsetCuda.empty()) {
// Find the highest available version of the CUDA tools.
std::vector<std::string> cudaTools;

View File

@ -115,6 +115,8 @@ public:
virtual bool IsDefaultToolset(const std::string& version) const;
virtual std::string GetAuxiliaryToolset() const;
bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
bool FindMakeProgram(cmMakefile* mf) override;
bool IsIPOSupported() const override { return true; }
@ -180,6 +182,7 @@ protected:
std::string DefaultMasmFlagTableName;
std::string DefaultNasmFlagTableName;
std::string DefaultRCFlagTableName;
bool SupportsUnityBuilds = false;
bool SystemIsWindowsCE;
bool SystemIsWindowsPhone;
bool SystemIsWindowsStore;

View File

@ -2115,9 +2115,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
const bool haveUnityBuild =
this->GeneratorTarget->GetPropertyAsBool("UNITY_BUILD");
if (haveUnityBuild &&
this->GlobalGenerator->GetVersion() >=
cmGlobalVisualStudioGenerator::VS15) {
if (haveUnityBuild && this->GlobalGenerator->GetSupportsUnityBuilds()) {
Elem e1(e0, "PropertyGroup");
e1.Element("EnableUnitySupport", "true");
}
@ -2223,9 +2221,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
this->WriteSource(e2, si.Source);
bool useNativeUnityBuild = false;
if (haveUnityBuild &&
this->GlobalGenerator->GetVersion() >=
cmGlobalVisualStudioGenerator::VS15) {
if (haveUnityBuild && this->GlobalGenerator->GetSupportsUnityBuilds()) {
// Magic value taken from cmGlobalVisualStudioVersionedGenerator.cxx
static const std::string vs15 = "141";
std::string toolset =
@ -2252,7 +2248,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
si.Source->GetProperty("UNITY_SOURCE_FILE"));
e2.Attribute("UnityFilesDirectory", unityDir);
} else {
// Visual Studio versions prior to 2017 do not know about unity
// Visual Studio versions prior to 2017 15.8 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;