mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 14:20:06 -06:00
cmVisualStudio10TargetGenerator: Refactor target framework selection
Split the selection from the generation of the resulting element(s).
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <cm/memory>
|
#include <cm/memory>
|
||||||
|
#include <cm/optional>
|
||||||
#include <cm/string_view>
|
#include <cm/string_view>
|
||||||
#include <cm/vector>
|
#include <cm/vector>
|
||||||
#include <cmext/algorithm>
|
#include <cmext/algorithm>
|
||||||
@@ -492,50 +493,67 @@ void cmVisualStudio10TargetGenerator::Generate()
|
|||||||
cmValue projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL");
|
cmValue projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL");
|
||||||
e1.Element("ProjectName", projLabel ? projLabel : this->Name);
|
e1.Element("ProjectName", projLabel ? projLabel : this->Name);
|
||||||
{
|
{
|
||||||
cmValue targetFramework =
|
cm::optional<std::string> targetFramework;
|
||||||
this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK");
|
cm::optional<std::string> targetFrameworkVersion;
|
||||||
if (targetFramework) {
|
cm::optional<std::string> targetFrameworkIdentifier;
|
||||||
if (targetFramework->find(';') != std::string::npos) {
|
cm::optional<std::string> targetFrameworkTargetsVersion;
|
||||||
e1.Element("TargetFrameworks", *targetFramework);
|
if (cmValue tf =
|
||||||
} else {
|
this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK")) {
|
||||||
e1.Element("TargetFramework", *targetFramework);
|
targetFramework = *tf;
|
||||||
}
|
} else if (cmValue vstfVer = this->GeneratorTarget->GetProperty(
|
||||||
} else {
|
"VS_DOTNET_TARGET_FRAMEWORK_VERSION")) {
|
||||||
// TODO: add deprecation warning for VS_* property?
|
// FIXME: Someday, add a deprecation warning for VS_* property.
|
||||||
cmValue p = this->GeneratorTarget->GetProperty(
|
targetFrameworkVersion = *vstfVer;
|
||||||
"VS_DOTNET_TARGET_FRAMEWORK_VERSION");
|
} else if (cmValue tfVer = this->GeneratorTarget->GetProperty(
|
||||||
if (!p) {
|
"DOTNET_TARGET_FRAMEWORK_VERSION")) {
|
||||||
p = this->GeneratorTarget->GetProperty(
|
targetFrameworkVersion = *tfVer;
|
||||||
"DOTNET_TARGET_FRAMEWORK_VERSION");
|
} else if (this->ProjectType == csproj &&
|
||||||
}
|
this->GlobalGenerator->TargetsWindowsCE() &&
|
||||||
std::string targetFrameworkVersion = p;
|
this->GlobalGenerator->GetVersion() ==
|
||||||
if (targetFrameworkVersion.empty() && this->ProjectType == csproj &&
|
cmGlobalVisualStudioGenerator::VS12) {
|
||||||
this->GlobalGenerator->TargetsWindowsCE() &&
|
// VS12 .NETCF default to .NET framework 3.9
|
||||||
this->GlobalGenerator->GetVersion() ==
|
targetFrameworkVersion = "v3.9";
|
||||||
cmGlobalVisualStudioGenerator::VS12) {
|
|
||||||
// VS12 .NETCF default to .NET framework 3.9
|
|
||||||
targetFrameworkVersion = "v3.9";
|
|
||||||
}
|
|
||||||
if (!targetFrameworkVersion.empty()) {
|
|
||||||
e1.Element("TargetFrameworkVersion", targetFrameworkVersion);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this->ProjectType == vcxproj &&
|
if (this->ProjectType == vcxproj &&
|
||||||
this->GlobalGenerator->TargetsWindowsCE()) {
|
this->GlobalGenerator->TargetsWindowsCE()) {
|
||||||
e1.Element("EnableRedirectPlatform", "true");
|
e1.Element("EnableRedirectPlatform", "true");
|
||||||
e1.Element("RedirectPlatformValue", this->Platform);
|
e1.Element("RedirectPlatformValue", this->Platform);
|
||||||
}
|
}
|
||||||
if (this->ProjectType == csproj &&
|
if (this->ProjectType == csproj) {
|
||||||
this->GlobalGenerator->TargetsWindowsCE()) {
|
if (this->GlobalGenerator->TargetsWindowsCE()) {
|
||||||
cmValue targetFrameworkId = this->GeneratorTarget->GetProperty(
|
// FIXME: These target VS_TARGET_FRAMEWORK* target properties
|
||||||
"VS_TARGET_FRAMEWORK_IDENTIFIER");
|
// are undocumented settings only ever supported for WinCE.
|
||||||
e1.Element("TargetFrameworkIdentifier",
|
// We need a better way to control these in general.
|
||||||
targetFrameworkId ? *targetFrameworkId
|
if (cmValue tfId = this->GeneratorTarget->GetProperty(
|
||||||
: "WindowsEmbeddedCompact");
|
"VS_TARGET_FRAMEWORK_IDENTIFIER")) {
|
||||||
cmValue targetFrameworkVer = this->GeneratorTarget->GetProperty(
|
targetFrameworkIdentifier = *tfId;
|
||||||
"VS_TARGET_FRAMEWORKS_TARGET_VERSION");
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (targetFrameworkVersion) {
|
||||||
|
e1.Element("TargetFrameworkVersion", *targetFrameworkVersion);
|
||||||
|
}
|
||||||
|
if (targetFrameworkIdentifier) {
|
||||||
|
e1.Element("TargetFrameworkIdentifier", *targetFrameworkIdentifier);
|
||||||
|
}
|
||||||
|
if (targetFrameworkTargetsVersion) {
|
||||||
e1.Element("TargetFrameworkTargetsVersion",
|
e1.Element("TargetFrameworkTargetsVersion",
|
||||||
targetFrameworkVer ? *targetFrameworkVer : "v8.0");
|
*targetFrameworkTargetsVersion);
|
||||||
}
|
}
|
||||||
if (!this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString()
|
if (!this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString()
|
||||||
.empty()) {
|
.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user