Skip to content

Commit ce0fc47

Browse files
bradkingkhouzam
authored andcommitted
VS: Do not fail on Windows 10 with VS 2015 if no SDK is available (#15929)
Since commit v3.4.0-rc1~5^2~1 (VS: Add support for selecting the Windows 10 SDK, 2015-09-30) the VS 2015 generator requires a Windows 10 SDK to be available when CMAKE_SYSTEM_VERSION specifies Windows 10 (e.g. when building on a Windows 10 host). Howewver, it is possible to install VS 2015 without any Windows 10 SDK. Instead of failing with an error message about the lack of a Windows 10 SDK, simply tolerate this case and use the default Windows 8.1 SDK. Since building for Windows Store still requires the SDK, retain the diagnostic in that case.
1 parent bbcdade commit ce0fc47

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ specification of a target Windows version to select a corresponding SDK.
88
The :variable:`CMAKE_SYSTEM_VERSION` variable may be set to specify a
99
version. Otherwise CMake computes a default version based on the Windows
1010
SDK versions available. The chosen Windows target version number is provided
11-
in ``CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION``.
11+
in ``CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION``. If no Windows 10 SDK
12+
is available this value will be empty.

Source/cmGlobalVisualStudio14Generator.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf)
115115
{
116116
if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
117117
{
118-
return this->SelectWindows10SDK(mf);
118+
return this->SelectWindows10SDK(mf, false);
119119
}
120120
return true;
121121
}
@@ -143,17 +143,18 @@ bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf)
143143
}
144144
if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
145145
{
146-
return this->SelectWindows10SDK(mf);
146+
return this->SelectWindows10SDK(mf, true);
147147
}
148148
return true;
149149
}
150150

151151
//----------------------------------------------------------------------------
152-
bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf)
152+
bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf,
153+
bool required)
153154
{
154155
// Find the default version of the Windows 10 SDK.
155156
this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion();
156-
if (this->WindowsTargetPlatformVersion.empty())
157+
if (required && this->WindowsTargetPlatformVersion.empty())
157158
{
158159
std::ostringstream e;
159160
e << "Could not find an appropriate version of the Windows 10 SDK"

Source/cmGlobalVisualStudio14Generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class cmGlobalVisualStudio14Generator:
3939
bool IsWindowsStoreToolsetInstalled() const;
4040

4141
virtual const char* GetIDEVersion() { return "14.0"; }
42-
virtual bool SelectWindows10SDK(cmMakefile* mf);
42+
virtual bool SelectWindows10SDK(cmMakefile* mf, bool required);
4343

4444
// Used to verify that the Desktop toolset for the current generator is
4545
// installed on the machine.

0 commit comments

Comments
 (0)