summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-03 18:31:04 (GMT)
committerBrad King <brad.king@kitware.com>2021-11-06 10:08:54 (GMT)
commitf97f8537f371daa073edce34f54743d1f261c022 (patch)
tree30f5e72adfe40f1d2ee6e468878081f62c38627c /Source
parente40cedddc0bcdd7d0317592a83fde42fd018f72f (diff)
downloadCMake-f97f8537f371daa073edce34f54743d1f261c022.zip
CMake-f97f8537f371daa073edce34f54743d1f261c022.tar.gz
CMake-f97f8537f371daa073edce34f54743d1f261c022.tar.bz2
VS: Model a default target framework
Add fields to the VS generator to select a target framework. Migrate the existing default for VS 12 .NET CF for Windows CE. Report the values in `CMAKE_VS_*` variables and use them for the CSharp compiler id project too. Issue: #22849
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx7
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx36
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h10
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx21
4 files changed, 64 insertions, 10 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index c11516d..6cab492 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -580,6 +580,13 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
this->DefaultPlatformToolset = this->SelectWindowsCEToolset();
+ if (this->GetVersion() == cmGlobalVisualStudioGenerator::VS12) {
+ // VS 12 .NET CF defaults to .NET framework 3.9 for Windows CE.
+ this->DefaultTargetFrameworkVersion = "v3.9";
+ this->DefaultTargetFrameworkIdentifier = "WindowsEmbeddedCompact";
+ this->DefaultTargetFrameworkTargetsVersion = "v8.0";
+ }
+
return true;
}
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 439d13e..1e45813 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -76,12 +76,48 @@ bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p,
this->GeneratorPlatform = p;
+ // FIXME: Add CMAKE_GENERATOR_PLATFORM field to set the framework.
+ // For now, just report the generator's default, if any.
+ if (cm::optional<std::string> const& targetFrameworkVersion =
+ this->GetTargetFrameworkVersion()) {
+ mf->AddDefinition("CMAKE_VS_TARGET_FRAMEWORK_VERSION",
+ *targetFrameworkVersion);
+ }
+ if (cm::optional<std::string> const& targetFrameworkIdentifier =
+ this->GetTargetFrameworkIdentifier()) {
+ mf->AddDefinition("CMAKE_VS_TARGET_FRAMEWORK_IDENTIFIER",
+ *targetFrameworkIdentifier);
+ }
+ if (cm::optional<std::string> const& targetFrameworkTargetsVersion =
+ this->GetTargetFrameworkTargetsVersion()) {
+ mf->AddDefinition("CMAKE_VS_TARGET_FRAMEWORK_TARGETS_VERSION",
+ *targetFrameworkTargetsVersion);
+ }
+
// The generator name does not contain the platform name, and so supports
// explicit platform specification. We handled that above, so pass an
// empty platform name to our base class implementation so it does not error.
return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform("", mf);
}
+cm::optional<std::string> const&
+cmGlobalVisualStudio8Generator::GetTargetFrameworkVersion() const
+{
+ return this->DefaultTargetFrameworkVersion;
+}
+
+cm::optional<std::string> const&
+cmGlobalVisualStudio8Generator::GetTargetFrameworkIdentifier() const
+{
+ return this->DefaultTargetFrameworkIdentifier;
+}
+
+cm::optional<std::string> const&
+cmGlobalVisualStudio8Generator::GetTargetFrameworkTargetsVersion() const
+{
+ return this->DefaultTargetFrameworkTargetsVersion;
+}
+
std::string cmGlobalVisualStudio8Generator::GetGenerateStampList()
{
return "generate.stamp.list";
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index 96e3553..b6ecdf0 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
+#include <cm/optional>
+
#include "cmGlobalVisualStudio71Generator.h"
/** \class cmGlobalVisualStudio8Generator
@@ -24,6 +26,10 @@ public:
bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
+ cm::optional<std::string> const& GetTargetFrameworkVersion() const;
+ cm::optional<std::string> const& GetTargetFrameworkIdentifier() const;
+ cm::optional<std::string> const& GetTargetFrameworkTargetsVersion() const;
+
/**
* Override Configure and Generate to add the build-system check
* target.
@@ -76,4 +82,8 @@ protected:
std::string Name;
std::string WindowsCEVersion;
+
+ cm::optional<std::string> DefaultTargetFrameworkVersion;
+ cm::optional<std::string> DefaultTargetFrameworkIdentifier;
+ cm::optional<std::string> DefaultTargetFrameworkTargetsVersion;
};
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index f765612..d2c49ae 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -507,12 +507,9 @@ void cmVisualStudio10TargetGenerator::Generate()
} 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";
+ } else if (this->ProjectType == csproj) {
+ targetFrameworkVersion =
+ this->GlobalGenerator->GetTargetFrameworkVersion();
}
if (this->ProjectType == vcxproj &&
this->GlobalGenerator->TargetsWindowsCE()) {
@@ -527,16 +524,20 @@ void cmVisualStudio10TargetGenerator::Generate()
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 (!targetFrameworkIdentifier) {
+ targetFrameworkIdentifier =
+ this->GlobalGenerator->GetTargetFrameworkIdentifier();
+ }
+ if (!targetFrameworkTargetsVersion) {
+ targetFrameworkTargetsVersion =
+ this->GlobalGenerator->GetTargetFrameworkTargetsVersion();
+ }
}
if (targetFramework) {
if (targetFramework->find(';') != std::string::npos) {