forked from aethersdr/AetherSDR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-fftw.ps1
More file actions
86 lines (69 loc) · 3.8 KB
/
Copy pathsetup-fftw.ps1
File metadata and controls
86 lines (69 loc) · 3.8 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
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
<#
.SYNOPSIS
Download and prepare FFTW3 prebuilt libraries for Windows x64.
.DESCRIPTION
Downloads the official FFTW 3.3.5 prebuilt 64-bit DLLs from fftw.org,
extracts them, and generates MSVC import libraries (.lib) using lib.exe.
The result is placed in third_party/fftw3/ ready for CMake.
Requires Visual Studio 2022 (for lib.exe).
.EXAMPLE
.\setup-fftw.ps1
#>
$ErrorActionPreference = "Stop"
$FftwUrl = "https://fftw.org/pub/fftw/fftw-3.3.5-dll64.zip"
$OutDir = "third_party\fftw3"
$ZipFile = "third_party\fftw3-dll64.zip"
$VsVars = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
# ── Check if already set up ──────────────────────────────────────────────
if (Test-Path "$OutDir\lib\fftw3.lib") {
Write-Host "FFTW3 already set up in $OutDir" -ForegroundColor Green
exit 0
}
# ── Create directories ───────────────────────────────────────────────────
New-Item -ItemType Directory -Force -Path "third_party" | Out-Null
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
New-Item -ItemType Directory -Force -Path "$OutDir\lib" | Out-Null
New-Item -ItemType Directory -Force -Path "$OutDir\include" | Out-Null
New-Item -ItemType Directory -Force -Path "$OutDir\bin" | Out-Null
# ── Download ─────────────────────────────────────────────────────────────
if (-not (Test-Path $ZipFile)) {
Write-Host "Downloading FFTW3 prebuilt DLLs..." -ForegroundColor Cyan
Invoke-WebRequest -Uri $FftwUrl -OutFile $ZipFile
}
# ── Extract ──────────────────────────────────────────────────────────────
Write-Host "Extracting..." -ForegroundColor Cyan
$tempDir = "third_party\fftw3-temp"
if (Test-Path $tempDir) { Remove-Item -Recurse -Force $tempDir }
Expand-Archive -Path $ZipFile -DestinationPath $tempDir -Force
# ── Copy files ───────────────────────────────────────────────────────────
Copy-Item "$tempDir\fftw3.h" "$OutDir\include\"
Copy-Item "$tempDir\libfftw3-3.dll" "$OutDir\bin\"
Copy-Item "$tempDir\libfftw3-3.def" "$OutDir\lib\"
# ── Import MSVC environment and generate .lib ────────────────────────────
Write-Host "Generating MSVC import library..." -ForegroundColor Cyan
if (-not (Test-Path $VsVars)) {
Write-Error "Visual Studio 2022 not found at: $VsVars"
exit 1
}
# Import MSVC env
$envVars = & cmd.exe /c "`"$VsVars`" >nul 2>&1 && set" 2>&1
foreach ($line in $envVars) {
if ($line -match "^([^=]+)=(.*)$") {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2], "Process")
}
}
# Generate .lib from .def
Push-Location "$OutDir\lib"
& lib.exe /machine:x64 /def:libfftw3-3.def /out:fftw3.lib 2>&1 | Out-Null
Pop-Location
if (-not (Test-Path "$OutDir\lib\fftw3.lib")) {
Write-Error "Failed to generate fftw3.lib"
exit 1
}
# ── Cleanup ──────────────────────────────────────────────────────────────
Remove-Item -Recurse -Force $tempDir
Remove-Item -Force $ZipFile
Write-Host "FFTW3 ready in $OutDir" -ForegroundColor Green
Write-Host " Header: $OutDir\include\fftw3.h"
Write-Host " Lib: $OutDir\lib\fftw3.lib"
Write-Host " DLL: $OutDir\bin\libfftw3-3.dll"