diff options
author | Brad King <brad.king@kitware.com> | 2021-11-08 17:38:28 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-11-08 17:38:48 (GMT) |
commit | c0e23058f61f09b3ef7fa26e2705cf46c68b2686 (patch) | |
tree | 02442eca1984a19a39bf8c9229f23f5e63b7bbf3 /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 7d653059a54b87b9d7abf1f7dee3fdd6eb4cda6f (diff) | |
parent | d51246c6621aa5025e06fcea720930ae00e6f448 (diff) | |
download | CMake-c0e23058f61f09b3ef7fa26e2705cf46c68b2686.zip CMake-c0e23058f61f09b3ef7fa26e2705cf46c68b2686.tar.gz CMake-c0e23058f61f09b3ef7fa26e2705cf46c68b2686.tar.bz2 |
Merge topic 'vs-framework-version'
d51246c662 VS: Default TargetFrameworkVersion to v4.7.2 for VS 2022
f97f8537f3 VS: Model a default target framework
e40cedddc0 cmVisualStudio10TargetGenerator: Refactor target framework selection
78782cc7dc cmGlobalVisualStudio8Generator: Refactor SetGeneratorPlatform
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6699
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 89 |
1 files changed, 54 insertions, 35 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4e93a4a..a7822b2 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -6,6 +6,7 @@ #include <set> #include <cm/memory> +#include <cm/optional> #include <cm/string_view> #include <cm/vector> #include <cmext/algorithm> @@ -492,50 +493,68 @@ void cmVisualStudio10TargetGenerator::Generate() cmValue projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL"); e1.Element("ProjectName", projLabel ? projLabel : this->Name); { - cmValue targetFramework = - this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK"); + cm::optional<std::string> targetFramework; + cm::optional<std::string> targetFrameworkVersion; + cm::optional<std::string> targetFrameworkIdentifier; + cm::optional<std::string> targetFrameworkTargetsVersion; + if (cmValue tf = + this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK")) { + targetFramework = *tf; + } else if (cmValue vstfVer = this->GeneratorTarget->GetProperty( + "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) { + // FIXME: Someday, add a deprecation warning for VS_* property. + targetFrameworkVersion = *vstfVer; + } else if (cmValue tfVer = this->GeneratorTarget->GetProperty( + "DOTNET_TARGET_FRAMEWORK_VERSION")) { + targetFrameworkVersion = *tfVer; + } else if (this->ProjectType == csproj) { + targetFrameworkVersion = + this->GlobalGenerator->GetTargetFrameworkVersion(); + } + if (this->ProjectType == vcxproj && + this->GlobalGenerator->TargetsWindowsCE()) { + e1.Element("EnableRedirectPlatform", "true"); + e1.Element("RedirectPlatformValue", this->Platform); + } + if (this->ProjectType == csproj) { + if (this->GlobalGenerator->TargetsWindowsCE()) { + // FIXME: These target VS_TARGET_FRAMEWORK* target properties + // are undocumented settings only ever supported for WinCE. + // We need a better way to control these in general. + if (cmValue tfId = this->GeneratorTarget->GetProperty( + "VS_TARGET_FRAMEWORK_IDENTIFIER")) { + targetFrameworkIdentifier = *tfId; + } + if (cmValue tfTargetsVer = this->GeneratorTarget->GetProperty( + "VS_TARGET_FRAMEWORKS_TARGET_VERSION")) { + targetFrameworkTargetsVersion = *tfTargetsVer; + } + } + if (!targetFrameworkIdentifier) { + targetFrameworkIdentifier = + this->GlobalGenerator->GetTargetFrameworkIdentifier(); + } + if (!targetFrameworkTargetsVersion) { + targetFrameworkTargetsVersion = + this->GlobalGenerator->GetTargetFrameworkTargetsVersion(); + } + } if (targetFramework) { if (targetFramework->find(';') != std::string::npos) { e1.Element("TargetFrameworks", *targetFramework); } else { e1.Element("TargetFramework", *targetFramework); } - } else { - // TODO: add deprecation warning for VS_* property? - cmValue p = this->GeneratorTarget->GetProperty( - "VS_DOTNET_TARGET_FRAMEWORK_VERSION"); - if (!p) { - p = this->GeneratorTarget->GetProperty( - "DOTNET_TARGET_FRAMEWORK_VERSION"); - } - std::string targetFrameworkVersion = p; - if (targetFrameworkVersion.empty() && this->ProjectType == csproj && - this->GlobalGenerator->TargetsWindowsCE() && - this->GlobalGenerator->GetVersion() == - cmGlobalVisualStudioGenerator::VS12) { - // VS12 .NETCF default to .NET framework 3.9 - targetFrameworkVersion = "v3.9"; - } - if (!targetFrameworkVersion.empty()) { - e1.Element("TargetFrameworkVersion", targetFrameworkVersion); - } } - if (this->ProjectType == vcxproj && - this->GlobalGenerator->TargetsWindowsCE()) { - e1.Element("EnableRedirectPlatform", "true"); - e1.Element("RedirectPlatformValue", this->Platform); + if (targetFrameworkVersion) { + e1.Element("TargetFrameworkVersion", *targetFrameworkVersion); } - if (this->ProjectType == csproj && - this->GlobalGenerator->TargetsWindowsCE()) { - cmValue targetFrameworkId = this->GeneratorTarget->GetProperty( - "VS_TARGET_FRAMEWORK_IDENTIFIER"); - e1.Element("TargetFrameworkIdentifier", - targetFrameworkId ? *targetFrameworkId - : "WindowsEmbeddedCompact"); - cmValue targetFrameworkVer = this->GeneratorTarget->GetProperty( - "VS_TARGET_FRAMEWORKS_TARGET_VERSION"); + if (targetFrameworkIdentifier) { + e1.Element("TargetFrameworkIdentifier", *targetFrameworkIdentifier); + } + if (targetFrameworkTargetsVersion) { e1.Element("TargetFrameworkTargetsVersion", - targetFrameworkVer ? *targetFrameworkVer : "v8.0"); + *targetFrameworkTargetsVersion); } if (!this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() .empty()) { |