1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 14:08:35 +08:00

VS: Defer Windows SDK selection until CMAKE_GENERATOR_PLATFORM is known

Prepare to teach `CMAKE_GENERATOR_PLATFORM` to affect SDK selection.
This commit is contained in:
Brad King
2023-03-31 13:21:29 -04:00
parent 8499374c6a
commit e259063b0a
8 changed files with 37 additions and 8 deletions

View File

@@ -525,6 +525,21 @@ bool cmGlobalVisualStudio10Generator::InitializeAndroid(cmMakefile* mf)
return false;
}
bool cmGlobalVisualStudio10Generator::InitializePlatform(cmMakefile* mf)
{
if (this->SystemName == "Windows" || this->SystemName == "WindowsStore") {
if (!this->InitializePlatformWindows(mf)) {
return false;
}
}
return this->cmGlobalVisualStudio8Generator::InitializePlatform(mf);
}
bool cmGlobalVisualStudio10Generator::InitializePlatformWindows(cmMakefile*)
{
return true;
}
bool cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
std::string& toolset) const
{

View File

@@ -183,6 +183,9 @@ protected:
virtual bool InitializeTegraAndroid(cmMakefile* mf);
virtual bool InitializeAndroid(cmMakefile* mf);
bool InitializePlatform(cmMakefile* mf) override;
virtual bool InitializePlatformWindows(cmMakefile* mf);
virtual bool ProcessGeneratorToolsetField(std::string const& key,
std::string const& value);

View File

@@ -137,7 +137,7 @@ bool cmGlobalVisualStudio14Generator::MatchesGeneratorName(
return false;
}
bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf)
bool cmGlobalVisualStudio14Generator::InitializePlatformWindows(cmMakefile* mf)
{
if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
return this->SelectWindows10SDK(mf);
@@ -162,9 +162,6 @@ bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf)
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
return this->SelectWindows10SDK(mf);
}
return true;
}

View File

@@ -30,7 +30,6 @@ protected:
cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
bool InitializeWindows(cmMakefile* mf) override;
bool InitializeWindowsStore(cmMakefile* mf) override;
bool InitializeAndroid(cmMakefile* mf) override;
bool SelectWindowsStoreToolset(std::string& toolset) const override;
@@ -39,6 +38,8 @@ protected:
// of the toolset is installed
bool IsWindowsStoreToolsetInstalled() const;
bool InitializePlatformWindows(cmMakefile* mf) override;
// Used to adjust the max-SDK-version calculation to accommodate user
// configuration.
std::string GetWindows10SDKMaxVersion(cmMakefile* mf) const;

View File

@@ -114,12 +114,21 @@ bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p,
*targetFrameworkTargetsVersion);
}
if (!this->InitializePlatform(mf)) {
return false;
}
// 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);
}
bool cmGlobalVisualStudio8Generator::InitializePlatform(cmMakefile*)
{
return true;
}
cm::optional<std::string> const&
cmGlobalVisualStudio8Generator::GetTargetFrameworkVersion() const
{

View File

@@ -60,6 +60,8 @@ protected:
cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
virtual bool InitializePlatform(cmMakefile* mf);
void AddExtraIDETargets() override;
std::string FindDevEnvCommand() override;

View File

@@ -885,7 +885,8 @@ cmGlobalVisualStudioVersionedGenerator::FindAuxToolset(
return AuxToolset::PropsMissing;
}
bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf)
bool cmGlobalVisualStudioVersionedGenerator::InitializePlatformWindows(
cmMakefile* mf)
{
// If the Win 8.1 SDK is installed then we can select a SDK matching
// the target Windows version.
@@ -896,7 +897,7 @@ bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf)
this->SetWindowsTargetPlatformVersion("8.1", mf);
return true;
}
return cmGlobalVisualStudio14Generator::InitializeWindows(mf);
return cmGlobalVisualStudio14Generator::InitializePlatformWindows(mf);
}
// Otherwise we must choose a Win 10 SDK even if we are not targeting
// Windows 10.

View File

@@ -61,7 +61,6 @@ protected:
VSVersion version, cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
bool InitializeWindows(cmMakefile* mf) override;
bool SelectWindowsStoreToolset(std::string& toolset) const override;
// Used to verify that the Desktop toolset for the current generator is
@@ -72,6 +71,8 @@ protected:
// of the toolset is installed
bool IsWindowsStoreToolsetInstalled() const;
bool InitializePlatformWindows(cmMakefile* mf) override;
// Check for a Win 8 SDK known to the registry or VS installer tool.
bool IsWin81SDKInstalled() const;