Build with ninja instructions

This commit is contained in:
Eelke Klein 2026-10-23 12:53:45 +02:00
parent 714e29d2cb
commit 04f525e2e9
No known key found for this signature in database

View file

@ -28,7 +28,7 @@ Configure with the vcpkg toolchain file. The first configure downloads and build
``` ```
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
cmake --build build cmake --build build --parallel
``` ```
To skip the test executables, add `-DBUILD_TESTS=OFF` to the configure command. To skip the test executables, add `-DBUILD_TESTS=OFF` to the configure command.
@ -39,7 +39,7 @@ Tested with Visual Studio 2022 (Professional) and Qt 6.8.2 (MSVC 2022, 64-bit).
``` ```
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DCMAKE_PREFIX_PATH=C:/Qt/6.8.2/msvc2022_64 cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DCMAKE_PREFIX_PATH=C:/Qt/6.8.2/msvc2022_64
cmake --build build --config Release cmake --build build --config Release --parallel
ctest --test-dir build -C Release --output-on-failure ctest --test-dir build -C Release --output-on-failure
``` ```
@ -51,6 +51,23 @@ C:\Qt\6.8.2\msvc2022_64\bin\windeployqt.exe --release build\pglab\Release\pglab.
If another Qt installation (for example one shipped with another program) is on your `PATH`, its `Qt6Core.dll` may be loaded instead, which causes "entry point not found" errors at startup. Deploying the DLLs next to the executables avoids this. If another Qt installation (for example one shipped with another program) is on your `PATH`, its `Qt6Core.dll` may be loaded instead, which causes "entry point not found" errors at startup. Deploying the DLLs next to the executables avoids this.
### Parallel builds with Ninja on Windows
Open an x64 Visual Studio 2022 Developer PowerShell. Ninja requires the compiler and Windows SDK environment from that shell; adding `cl.exe` to `PATH` alone can leave the linker unable to find `kernel32.lib`.
With `VCPKG_ROOT` set, run these PowerShell commands (adjust the Qt path for your installation):
```powershell
cmake -S . -B build/ninja-release -G Ninja -DCMAKE_BUILD_TYPE=Release "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DCMAKE_PREFIX_PATH=C:/Qt/6.8.2/msvc2022_64
cmake --build build/ninja-release --parallel 8
$env:PATH = "C:\Qt\6.8.2\msvc2022_64\bin;$PWD\build\ninja-release\vcpkg_installed\x64-windows\bin;$env:PATH"
ctest --test-dir build/ninja-release --output-on-failure
```
`--parallel 8` allows eight build jobs; adjust the number to suit your machine. Ninja also builds in parallel by default. `CMAKE_BUILD_TYPE` selects Release at configure time, and the app is written to `build/ninja-release/pglab/pglab.exe`.
Use a separate build directory when changing generators or adding a toolchain to an existing configuration. The directory above keeps the Ninja configuration separate from an existing Visual Studio build. The Qt prefix and vcpkg toolchain are both needed: Qt is installed separately, while vcpkg supplies the other dependencies.
## Running the tests ## Running the tests
From the build directory, run: From the build directory, run: