-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_vcpkg_path.ps1
30 lines (24 loc) · 1.26 KB
/
set_vcpkg_path.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Function Get-FileName
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $(get-location).Path
$OpenFileDialog.filter = "CMake (*.cmake)| *.cmake"
$OpenFileDialog.title = "Select vcpkg.cmake"
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
}
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
[System.Windows.Forms.MessageBox]::Show("Please select the vcpkg.cmake file in the next dialog.
It is usually located in [vcpkg-root]/scripts/buildsystems/","Graphics2",0)
$vcpkgpath = Get-FileName
if($vcpkgpath -eq ""){
[System.Windows.Forms.MessageBox]::Show("Error setting the path.","Graphics2",0)
Exit
}
$cmakesettingspath = "./CMakeSettings.json"
$a = Get-Content $cmakesettingspath -raw | ConvertFrom-Json
$a.configurations.variables | % {if($_.name -eq 'CMAKE_TOOLCHAIN_FILE'){$_.value=$vcpkgpath}}
$a | ConvertTo-Json -Depth 20 | set-content $cmakesettingspath
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
[System.Windows.Forms.MessageBox]::Show("Finished setting vcpkg path in CMakeSettings.json","Graphics2",0)