summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-04-17 14:29:07 +0000
committerKitware Robot <kwrobot@kitware.com>2017-04-17 10:29:15 -0400
commitc0323cbf5f407e9a231c8e7d55801ef3723748bd (patch)
tree8679b14cf1b89127ce1ec91168624229e5637925
parenteb974170cbfbbc202ba7bd3688879a239544f1e2 (diff)
parentfee011946e4fe0fc20f2f6bf016851402241d554 (diff)
downloadcmake-c0323cbf5f407e9a231c8e7d55801ef3723748bd.tar.gz
Merge topic 'vs-custom-kits-dir'
fee01194 VS: Add an environment variable for the Windows 10 kits directory b80c6d12 VS: Refactor Win 10 Kits root detection to support multiple roots Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !696
-rw-r--r--Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst5
-rw-r--r--Modules/InstallRequiredSystemLibraries.cmake6
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx46
3 files changed, 44 insertions, 13 deletions
diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
index e0be3a43e1..83b9bc1fdd 100644
--- a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
+++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
@@ -10,3 +10,8 @@ version. Otherwise CMake computes a default version based on the Windows
SDK versions available. The chosen Windows target version number is provided
in ``CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION``. If no Windows 10 SDK
is available this value will be empty.
+
+One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable*
+to an absolute path to tell CMake to look for Windows 10 SDKs in
+a custom location. The specified directory is expected to contain
+``Include/10.0.*`` directories.
diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake
index a3478a387f..6d33fc6ecd 100644
--- a/Modules/InstallRequiredSystemLibraries.cmake
+++ b/Modules/InstallRequiredSystemLibraries.cmake
@@ -31,6 +31,11 @@
# app-local deployment (e.g. to Windows XP). This is meaningful
# only with MSVC from Visual Studio 2015 or higher.
#
+# One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable*
+# to an absolute path to tell CMake to look for Windows 10 SDKs in
+# a custom location. The specified directory is expected to contain
+# ``Redist/ucrt/DLLs/*`` directories.
+#
# ``CMAKE_INSTALL_MFC_LIBRARIES``
# Set to TRUE to install the MSVC MFC runtime libraries.
#
@@ -258,6 +263,7 @@ if(MSVC)
set(programfilesx86 "ProgramFiles(x86)")
find_path(WINDOWS_KITS_DIR NAMES Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
PATHS
+ $ENV{CMAKE_WINDOWS_KITS_10_DIR}
"${windows_kits_dir}"
"$ENV{ProgramFiles}/Windows Kits/10"
"$ENV{${programfilesx86}}/Windows Kits/10"
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index d2ac36b1c5..df086d3fdf 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -217,24 +217,44 @@ struct NoWindowsH
std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
{
#if defined(_WIN32) && !defined(__CYGWIN__)
- // This logic is taken from the vcvarsqueryregistry.bat file from VS2015
- // Try HKLM and then HKCU.
- std::string win10Root;
- if (!cmSystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
- "Windows Kits\\Installed Roots;KitsRoot10",
- win10Root, cmSystemTools::KeyWOW64_32) &&
- !cmSystemTools::ReadRegistryValue(
- "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\"
- "Windows Kits\\Installed Roots;KitsRoot10",
- win10Root, cmSystemTools::KeyWOW64_32)) {
+ std::vector<std::string> win10Roots;
+
+ {
+ std::string win10Root;
+ if (cmSystemTools::GetEnv("CMAKE_WINDOWS_KITS_10_DIR", win10Root)) {
+ cmSystemTools::ConvertToUnixSlashes(win10Root);
+ win10Roots.push_back(win10Root);
+ }
+ }
+
+ {
+ // This logic is taken from the vcvarsqueryregistry.bat file from VS2015
+ // Try HKLM and then HKCU.
+ std::string win10Root;
+ if (cmSystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+ "Windows Kits\\Installed Roots;KitsRoot10",
+ win10Root, cmSystemTools::KeyWOW64_32) ||
+ cmSystemTools::ReadRegistryValue(
+ "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\"
+ "Windows Kits\\Installed Roots;KitsRoot10",
+ win10Root, cmSystemTools::KeyWOW64_32)) {
+ cmSystemTools::ConvertToUnixSlashes(win10Root);
+ win10Roots.push_back(win10Root);
+ }
+ }
+
+ if (win10Roots.empty()) {
return std::string();
}
std::vector<std::string> sdks;
- std::string path = win10Root + "Include/*";
// Grab the paths of the different SDKs that are installed
- cmSystemTools::GlobDirs(path, sdks);
+ for (std::vector<std::string>::iterator i = win10Roots.begin();
+ i != win10Roots.end(); ++i) {
+ std::string path = *i + "/Include/*";
+ cmSystemTools::GlobDirs(path, sdks);
+ }
// Skip SDKs that do not contain <um/windows.h> because that indicates that
// only the UCRT MSIs were installed for them.