Skip to content

Commit 4de17ab

Browse files
committed
fixed simple build on Windows
1 parent 283f7cf commit 4de17ab

2 files changed

Lines changed: 47 additions & 31 deletions

File tree

README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,6 @@ export LD_LIBRARY_PATH=~/Qt/6.8.3/gcc_64/lib:$LD_LIBRARY_PATH
8080

8181
Alternatively, build CLI-only with `-DLSLTEMPLATE_BUILD_GUI=OFF` to avoid the Qt dependency.
8282

83-
### Single-command build and run
84-
85-
From the repo root, one command can configure, build, install, and start the server. Dependencies (liblsl, hidapi, tiny-AES-c) are fetched automatically. Requires CMake 3.25+ and PowerShell Core (`pwsh`) for the run script.
86-
87-
**Windows (PowerShell):**
88-
89-
```powershell
90-
# Build self-contained install only
91-
cmake --workflow --preset emotiv
92-
cmake --install build --config Release
93-
94-
# Build and start collecting data (single command)
95-
pwsh ./run.ps1
96-
```
97-
98-
**Linux / macOS:**
99-
100-
```bash
101-
# Build self-contained install only
102-
cmake --workflow --preset emotiv
103-
cmake --install build --config Release
104-
105-
# Build and start collecting data (single command)
106-
pwsh ./run.ps1
107-
```
108-
109-
The preset builds only `emotiv_lsl` (no Qt/CLI). The executable and bundled LSL library end up in `build/install/`.
110-
11183
### Quick Start
11284

11385
```bash
@@ -235,6 +207,30 @@ For automated signing and notarization, the workflow expects these secrets from
235207
1. Go to Organization Settings → Secrets and variables → Actions
236208
2. For each secret, click to edit and under "Repository access" select the repositories that need access
237209

238-
## License
210+
### Single-command build and run
211+
212+
From the repo root, one command can configure, build, install, and start the server. Dependencies (liblsl, hidapi, tiny-AES-c) are fetched automatically. Requires CMake 3.25+ and PowerShell Core (`pwsh`) for the run script.
213+
214+
**Windows (PowerShell):**
215+
216+
```powershell
217+
# Build self-contained install only
218+
cmake --workflow --preset emotiv
219+
cmake --install build --config Release
239220
240-
MIT License - see LICENSE
221+
# Build and start collecting data (single command)
222+
pwsh ./run.ps1
223+
```
224+
225+
**Linux / macOS:**
226+
227+
```bash
228+
# Build self-contained install only
229+
cmake --workflow --preset emotiv
230+
cmake --install build --config Release
231+
232+
# Build and start collecting data (single command)
233+
pwsh ./run.ps1
234+
```
235+
236+
The preset builds only `emotiv_lsl` (no Qt/CLI). The executable and bundled LSL library end up in `build/install/`.

run.ps1

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,34 @@
99
the binary), then launches emotiv_lsl. All C++ dependencies (liblsl, hidapi,
1010
tiny-AES-c) are fetched automatically by CMake on first run.
1111
12+
If a stale CMakeCache.txt exists from a different generator, it is removed
13+
automatically before configuring so the build stays consistent cross-platform.
14+
1215
.EXAMPLE
1316
pwsh ./run.ps1
1417
#>
1518

1619
Set-StrictMode -Version Latest
1720
$ErrorActionPreference = 'Stop'
1821

19-
$root = $PSScriptRoot
22+
$root = $PSScriptRoot
23+
$cacheFile = Join-Path $root "build" "CMakeCache.txt"
24+
$wantedGen = if ($IsWindows) { "Visual Studio 17 2022" } else { "Ninja" }
25+
26+
# Tell CMake which generator to use (preset has none specified so this env var
27+
# is the authoritative source on all platforms).
28+
$env:CMAKE_GENERATOR = $wantedGen
29+
30+
# Remove stale cache when the stored generator doesn't match the wanted one.
31+
# This happens after a previous build with a different generator.
32+
# Object files in build/ are also removed so CMake starts clean.
33+
if (Test-Path $cacheFile) {
34+
$cachedGen = (Select-String -Path $cacheFile -Pattern '^CMAKE_GENERATOR:INTERNAL=(.+)').Matches.Groups[1].Value
35+
if ($cachedGen -and $cachedGen -ne $wantedGen) {
36+
Write-Host "==> Stale cache detected (was: $cachedGen, want: $wantedGen). Clearing build/ for clean configure." -ForegroundColor Yellow
37+
Remove-Item -Recurse -Force (Join-Path $root "build")
38+
}
39+
}
2040

2141
Write-Host "==> cmake --workflow --preset emotiv" -ForegroundColor Cyan
2242
cmake --workflow --preset emotiv

0 commit comments

Comments
 (0)