playground-sdk/build.bat

16 lines
869 B
Batchfile

@echo off
rem Configure + build (x64, Ninja, MSVC) and run tests. Usage: build.bat [Release|Debug] [noTest]
setlocal
where cl >nul 2>nul || (echo MSVC cl not found. Open an x64 Developer Command Prompt. & exit /b 1)
where cmake >nul 2>nul || (echo CMake not found on PATH. Install CMake or add it to PATH. & exit /b 1)
where ninja >nul 2>nul || (echo Ninja not found on PATH. Install Ninja or add it to PATH. & exit /b 1)
where ctest >nul 2>nul || (echo CTest not found on PATH. Add the CMake bin directory to PATH. & exit /b 1)
set "CFG=%~1"
if "%CFG%"=="" set "CFG=Release"
set "SRC=%~dp0"
set "BLD=%SRC%build"
cmake -S "%SRC%." -B "%BLD%" -G Ninja -DCMAKE_BUILD_TYPE=%CFG% -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl || exit /b 1
cmake --build "%BLD%" || exit /b 1
if /i "%~2"=="noTest" exit /b 0
ctest --test-dir "%BLD%" --output-on-failure
exit /b %errorlevel%