-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.ps1
More file actions
56 lines (50 loc) · 2.38 KB
/
Copy pathconfigure.ps1
File metadata and controls
56 lines (50 loc) · 2.38 KB
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
#!/usr/bin/env pwsh
$CMakeFile = "CMakeLists.txt"
function Show-Help {
Write-Host "Usage: ./configure.ps1 [OPTIONS]"
Write-Host ""
Write-Host "Standard options:"
Write-Host " --fresh Fresh reconfigure"
Write-Host " -B=DIR --dir=DIR --build-dir=DIR Build directory (./ by default)"
Write-Host " -G=GEN --generator=GEN CMake generator (Ninja, Unix Makefiles, etc.)"
Write-Host " --cc=PATH C compiler"
Write-Host " --cxx=PATH C++ compiler"
Write-Host " --ld=PATH Linker"
Write-Host " --ar=PATH Archiver"
Write-Host " --cflags=FLAGS C compiler flags"
Write-Host " --cxxflags=FLAGS C++ compiler flags"
Write-Host " --ldflags=FLAGS Linker flags"
Write-Host ""
Write-Host "Project options (from $CMakeFile):"
Write-Host ""
Get-Content $CMakeFile | ForEach-Object {
if ($_ -match 'option\s*\(\s*([A-Za-z0-9_]+)\s*"([^"]*)"\s*([A-Za-z0-9_]*)') {
"{0,-48} {1} (default: {2})" -f $Matches[1], $Matches[2], $Matches[3]
}
}
exit
}
$CMakeFlags = @()
$ExtraArgs = @()
$Generator = $null
foreach ($arg in $args) {
switch -regex ($arg) {
'^--help$|^-h$' { Show-Help }
'^--fresh$' { $CMakeFlags += $($matches[0]) }
'^-B=(.+)|^--dir=(.+)|^--build-dir=(.+)' { $CMakeFlags += $($matches[1]) }
'^-G=(.+)|^--generator=(.+)' { $Generator = $matches[1] }
'^--cc=(.+)' { $CMakeFlags += "-DCMAKE_C_COMPILER=$($matches[1])" }
'^--cxx=(.+)' { $CMakeFlags += "-DCMAKE_CXX_COMPILER=$($matches[1])" }
'^--ld=(.+)' { $CMakeFlags += "-DCMAKE_LINKER=$($matches[1])" }
'^--ar=(.+)' { $CMakeFlags += "-DCMAKE_AR=$($matches[1])" }
'^--cflags=(.+)' { $CMakeFlags += "-DCMAKE_C_FLAGS=`"$($matches[1])`"" }
'^--cxxflags=(.+)' { $CMakeFlags += "-DCMAKE_CXX_FLAGS=`"$($matches[1])`"" }
'^--ldflags=(.+)' { $CMakeFlags += "-DCMAKE_EXE_LINKER_FLAGS=`"$($matches[1])`"" }
default { $ExtraArgs += "-D" + $arg }
}
}
if ($Generator) {
cmake -S . -B build -G $Generator @CMakeFlags @ExtraArgs
} else {
cmake -S . -B build @CMakeFlags @ExtraArgs
}