-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmake.ps1
62 lines (50 loc) · 1.55 KB
/
cmake.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
# Script parameters.
Param(
[String]$installTo = "install/", # Relative path (CMAKE_INSTALL_PREFIX)
[String]$buildTo = "", # Relative path to source directory
[String]$OpenCV,
[String]$OpenEXR,
[String]$TBB,
[String]$HDF5,
[String]$config = "Release",
[Boolean]$x64 = $true,
[Boolean]$verbose = $false,
[String]$logFile = "",
[String]$options = "" # CMake options (i.e. --debug-output or --trace[-expand])
)
# Build up a command to invoke.
$invoke = "cmake CMakeLists.txt "
if (![String]::IsNullOrEmpty($buildTo)) {
$invoke += "-B`"$($buildTo)`" "
}
$invoke += "-DCMAKE_BUILD_TYPE=`"$($config)`" "
if ($x64) {
$invoke += "-G `"Visual Studio 15 2017 Win64`" "
} else {
$invoke += "-G `"Visual Studio 15 2017`" "
}
if (![String]::IsNullOrEmpty($installTo)) {
$invoke += "-DCMAKE_INSTALL_PREFIX:STRING=`"$($installTo)`" "
}
if (![String]::IsNullOrEmpty($OpenCV)) {
$invoke += "-DOpenCV_DIR:STRING=`"$($OpenCV)`" "
}
if (![String]::IsNullOrEmpty($OpenEXR)) {
$invoke += "-DOPENEXR_LOCATION:STRING=`"$($OpenEXR)`" "
}
if (![String]::IsNullOrEmpty($TBB)) {
$invoke += "-DTBB_DIR:STRING=`"$($TBB)`" "
}
if (![String]::IsNullOrEmpty($HDF5)) {
$invoke += "-DHDF5_ROOT:STRING=`"$($HDF5)`" "
}
if ($verbose) {
$invoke += "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON "
}
$invoke += "$($options) "
Write-Host "Invoking $($invoke)..."
if (![String]::IsNullOrEmpty($logFile)) {
Invoke-Expression $invoke | Tee-Object -FilePath $logFile
} else {
Invoke-Expression $invoke
}