forked from Azure/azure-remote-rendering-asset-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenerateSolution.ps1
103 lines (77 loc) · 2.38 KB
/
GenerateSolution.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
param
(
[Parameter(Mandatory = $False)] [string] $Destination = "$PSScriptRoot\Workspace",
[Parameter(Mandatory = $False)] [ValidateSet('vs2019', 'vs2022')] $Solution = "vs2022",
[Parameter(Mandatory = $False)] [string] $Vcpkg = ""
)
Write-Host ""
Write-Host "=== Generating ARRT Solution ==="
Write-Host ""
Write-Host "Destination Path: $Destination"
Write-Host "Solution for: $Solution"
& cmake.exe --version
if ($null -eq (Get-Command "nuget.exe" -ErrorAction SilentlyContinue)) {
throw "Unable to find nuget.exe in your PATH environment variable."
}
if ($null -eq (Get-Command "cmake.exe" -ErrorAction SilentlyContinue)) {
throw "Unable to find cmake.exe in your PATH environment variable."
}
if ($null -eq $env:Qt6_DIR) {
Write-Host "Environment variable 'Qt6_DIR' is not set."
}
else {
Write-Host "Environment variable Qt6_DIR is set to: '$env:Qt6_DIR'."
if (-not (Test-Path $env:Qt6_DIR)) {
throw "Environment variable Qt6_DIR points to non-existing directory: '$env:Qt6_DIR'."
}
}
$CacheFile = $Destination + "\CMakeCache.txt"
if (Test-Path -Path $CacheFile -PathType leaf) {
Remove-Item $CacheFile
}
if ("" -eq $Vcpkg) {
$VcpkgPath = $Destination + "\vcpkg"
Write-Host ""
Write-Host "=== Setting up vcpkg ==="
Write-Host ""
if ((Test-Path -Path $VcpkgPath) -eq $false) {
git clone https://github.com/microsoft/vcpkg "$Destination\vcpkg"
# could check out a fixed commit, but we'll just try latest for now
}
# bootstrap vcpkg
&$VcpkgPath\bootstrap-vcpkg.bat
# get Azure Storage SDK through vcgpk
&$VcpkgPath\vcpkg.exe install azure-storage-blobs-cpp:x64-windows
if (!$?) {
throw "Vcpkg error $LASTEXITCODE, see log above."
}
# get CppRest SDK through vcgpk
&$VcpkgPath\vcpkg.exe install cpprestsdk:x64-windows
if (!$?) {
throw "Vcpkg error $LASTEXITCODE, see log above."
}
}
else {
$VcpkgPath = $Vcpkg
}
Write-Host ""
Write-Host "Using vcpkg path '$VcpkgPath'"
Write-Host ""
Write-Host ""
Write-Host "=== Running CMake ==="
Write-Host ""
$CMAKE_ARGS = @("-S", "$PSScriptRoot")
$CMAKE_ARGS += @("-B", "$Destination")
$CMAKE_ARGS += @("-A", "x64")
$CMAKE_ARGS += "-G"
if ($Solution -eq "vs2022") {
$CMAKE_ARGS += "Visual Studio 17 2022"
}
else {
$CMAKE_ARGS += "Visual Studio 16 2019"
}
$CMAKE_ARGS += "-DCMAKE_TOOLCHAIN_FILE=$VcpkgPath\scripts\buildsystems\vcpkg.cmake"
& cmake.exe $CMAKE_ARGS
if (!$?) {
throw "CMake error $LASTEXITCODE, see log above."
}