diff options
author | Adeel Mujahid <adeelbm@outlook.com> | 2018-02-11 19:55:36 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-02-11 19:55:36 +0300 |
commit | b723f90c611a2c79a0921f95c7299ebb7325eb59 (patch) | |
tree | dd38d8f7f1043301ef80e27439c5f801347b4451 /src/Native | |
parent | d4815040efa9650c67ac466f1dfffb93a6b6983d (diff) |
Improve CMake detection on Windows when not in PATH (#5372)
In CMake v10.2, the key `hklm:\SOFTWARE\Kitware` returns:
```powershell
Hive: HKEY_LOCAL_MACHINE\SOFTWARE\Kitware
Name Property
---- --------
CMake InstallDir : C:\Program Files\CMake\
```
with no space after `CMake` and property name `InstallDir`,
instead of `'(default)'`.
Diffstat (limited to 'src/Native')
-rw-r--r-- | src/Native/probe-win.ps1 | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Native/probe-win.ps1 b/src/Native/probe-win.ps1 index 70030b14d..2eb96ea40 100644 --- a/src/Native/probe-win.ps1 +++ b/src/Native/probe-win.ps1 @@ -6,7 +6,7 @@ function GetCMakeVersions $items = @() $items += @(Get-ChildItem hklm:\SOFTWARE\Wow6432Node\Kitware -ErrorAction SilentlyContinue) $items += @(Get-ChildItem hklm:\SOFTWARE\Kitware -ErrorAction SilentlyContinue) - return $items | where { $_.PSChildName.StartsWith("CMake ") } + return $items | where { $_.PSChildName.StartsWith("CMake") } } function GetCMakeInfo($regKey) @@ -17,7 +17,13 @@ function GetCMakeInfo($regKey) catch { return $null } - $cmakeDir = (Get-ItemProperty $regKey.PSPath).'(default)' + $itemProperty = Get-ItemProperty $regKey.PSPath; + if (Get-Member -inputobject $itemProperty -name "InstallDir" -Membertype Properties) { + $cmakeDir = $itemProperty.InstallDir + } + else { + $cmakeDir = $itemProperty.'(default)' + } $cmakePath = [System.IO.Path]::Combine($cmakeDir, "bin\cmake.exe") if (![System.IO.File]::Exists($cmakePath)) { return $null |