forked from ezEngine/ezEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunCMake.ps1
117 lines (90 loc) · 3.21 KB
/
RunCMake.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
param
(
[Parameter(Mandatory = $True)] [ValidateSet('Win64vs2019', 'Uwp64vs2019', 'Win64vs2022', 'Uwp64vs2022')][string] $Target,
[switch]$NoUnityBuild,
[switch]$NoSubmoduleUpdate,
[string]$SolutionName
)
Set-Location $PSScriptRoot
if ($NoSubmoduleUpdate -eq $False) {
$CURRENT_COMMIT = git log -n 1 --format=%H
Write-Host "Current commit: $CURRENT_COMMIT"
$UPDATE_SUBMODULES = $True
$LAST_UPDATE_FILE = "$PSScriptRoot\Data\Content\AssetCache\LastSubmoduleUpdate.txt"
if (Test-Path $LAST_UPDATE_FILE -PathType Leaf -ErrorAction SilentlyContinue) {
$LAST_COMMIT = Get-Content -Path $LAST_UPDATE_FILE
if ($CURRENT_COMMIT -eq $LAST_COMMIT) {
Write-Host "Submodules already up-to-date."
$UPDATE_SUBMODULES = $False
}
else {
Write-Host "Submodules were last updated at commit: $LAST_COMMIT"
}
}
if ($UPDATE_SUBMODULES) {
Write-Host "Updating submodules"
git submodule init
git submodule update
Out-File ( New-Item -Path $LAST_UPDATE_FILE -Force) -InputObject $CURRENT_COMMIT
}
}
$CMAKE_ARGS = @("-S", "$PSScriptRoot")
if ($NoUnityBuild) {
$CMAKE_ARGS += "-DEZ_ENABLE_FOLDER_UNITY_FILES:BOOL=OFF"
}
else {
$CMAKE_ARGS += "-DEZ_ENABLE_FOLDER_UNITY_FILES:BOOL=ON"
}
if ($SolutionName -ne "") {
$CMAKE_ARGS += "-DEZ_SOLUTION_NAME:STRING='${SolutionName}'"
}
$CMAKE_ARGS += "-G"
Write-Host ""
if ($Target -eq "Win64vs2019") {
Write-Host "=== Generating Solution for Visual Studio 2019 x64 ==="
$CMAKE_ARGS += "Visual Studio 16 2019"
$CMAKE_ARGS += "-A"
$CMAKE_ARGS += "x64"
$CMAKE_ARGS += "-B"
$CMAKE_ARGS += "$PSScriptRoot\Workspace\vs2019x64"
}
elseif ($Target -eq "Uwp64vs2019") {
Write-Host "=== Generating Solution for Visual Studio 2019 x64 UWP ==="
$CMAKE_ARGS += "Visual Studio 16 2019"
$CMAKE_ARGS += "-A"
$CMAKE_ARGS += "x64"
$CMAKE_ARGS += "-B"
$CMAKE_ARGS += "$PSScriptRoot\Workspace\vs2019x64uwp"
$CMAKE_ARGS += "-DCMAKE_TOOLCHAIN_FILE=$PSScriptRoot\Code\BuildSystem\CMake\toolchain-winstore.cmake"
$CMAKE_ARGS += "-DEZ_ENABLE_QT_SUPPORT:BOOL=OFF"
$CMAKE_ARGS += "-DEZ_BUILD_FILTER='UwpProjects'"
}
elseif ($Target -eq "Win64vs2022") {
Write-Host "=== Generating Solution for Visual Studio 2022 x64 ==="
$CMAKE_ARGS += "Visual Studio 17 2022"
$CMAKE_ARGS += "-A"
$CMAKE_ARGS += "x64"
$CMAKE_ARGS += "-B"
$CMAKE_ARGS += "$PSScriptRoot\Workspace\vs2022x64"
}
elseif ($Target -eq "Uwp64vs2022") {
Write-Host "=== Generating Solution for Visual Studio 2022 x64 UWP ==="
$CMAKE_ARGS += "Visual Studio 17 2022"
$CMAKE_ARGS += "-A"
$CMAKE_ARGS += "x64"
$CMAKE_ARGS += "-B"
$CMAKE_ARGS += "$PSScriptRoot\Workspace\vs2022x64uwp"
$CMAKE_ARGS += "-DCMAKE_TOOLCHAIN_FILE=$PSScriptRoot\Code\BuildSystem\CMake\toolchain-winstore.cmake"
$CMAKE_ARGS += "-DEZ_ENABLE_QT_SUPPORT:BOOL=OFF"
$CMAKE_ARGS += "-DEZ_BUILD_FILTER='UwpProjects'"
}
else {
throw "Unknown target '$Target'."
}
Write-Host ""
Write-Host "Running cmake.exe $CMAKE_ARGS"
Write-Host ""
&Data\Tools\Precompiled\cmake\bin\cmake.exe $CMAKE_ARGS
if (!$?) {
throw "CMake failed with exit code '$LASTEXITCODE'."
}