summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-05 12:54:14 (GMT)
committerBrad King <brad.king@kitware.com>2021-11-06 10:08:48 (GMT)
commite40cedddc0bcdd7d0317592a83fde42fd018f72f (patch)
tree6dd87ae8312e6e9888115a897024b85428fa3e12 /Source
parent78782cc7dc9f4efa2e3a19c174dca0129d99af2e (diff)
downloadCMake-e40cedddc0bcdd7d0317592a83fde42fd018f72f.zip
CMake-e40cedddc0bcdd7d0317592a83fde42fd018f72f.tar.gz
CMake-e40cedddc0bcdd7d0317592a83fde42fd018f72f.tar.bz2
cmVisualStudio10TargetGenerator: Refactor target framework selection
Split the selection from the generation of the resulting element(s).
Diffstat (limited to 'Source')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx88
1 files changed, 53 insertions, 35 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 1ea0461..f765612 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,67 @@ 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 &&
+ this->GlobalGenerator->TargetsWindowsCE() &&
+ this->GlobalGenerator->GetVersion() ==
+ cmGlobalVisualStudioGenerator::VS12) {
+ // VS12 .NETCF default to .NET framework 3.9
+ targetFrameworkVersion = "v3.9";
+ }
+ 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;
+ } else {
+ targetFrameworkIdentifier = "WindowsEmbeddedCompact";
+ }
+ if (cmValue tfTargetsVer = this->GeneratorTarget->GetProperty(
+ "VS_TARGET_FRAMEWORKS_TARGET_VERSION")) {
+ targetFrameworkTargetsVersion = *tfTargetsVer;
+ } else {
+ targetFrameworkTargetsVersion = "v8.0";
+ }
+ }
+ }
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()) {