-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cmd
66 lines (51 loc) · 1.6 KB
/
build.cmd
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
@echo off
setlocal enabledelayedexpansion
set "project_root=%cd%"
set "vcpkg_root=%USERPROFILE%\vcpkg"
@REM Check if vcpkg is installed
if not exist %vcpkg_root% (
echo Warning: vcpkg is not installed.
echo Installing vcpkg...
cd %USERPROFILE%
@REM Download vcpkg using Git
git clone https://github.com/microsoft/vcpkg.git
@REM Run the vcpkg installation script
cd vcpkg && bootstrap-vcpkg.bat
echo vcpkg was successfully installed.
echo Please rerun this script.
cd %project_root%
)
@REM Check if an argument is provided and validate it
if "%~1"=="" (
@REM If no arguments are provided, set build type to Debug
set "build_type=Debug"
) else (
@REM Convert the argument to lowercase
set "build_type=%~1"
set "build_type=!build_type:~0,1!!build_type:~1!"
@REM Check if the provided argument is either Release or Debug
if /I "!build_type!"=="release" (
set "build_type=Release"
) else if /I "!build_type!"=="debug" (
set "build_type=Debug"
) else (
echo Error: Invalid build type '%~1'.
echo Please specify either 'Release' or 'Debug'.
exit /b 1
)
)
@REM Build type message
echo Build type: %build_type%
@REM Set build directory
set "build_dir=build\%build_type%"
@REM Run cmake with the appropriate build type
cmake -S . -B %build_dir% -G "Ninja" -DCMAKE_BUILD_TYPE=%build_type%
@REM Build the targets
cmake --build %build_dir% --parallel 4
if /I "!build_type!"=="Release" (
cmake --install %build_dir%
)
@REM Run tests
set "test_dir=%project_root%\%build_dir%\test"
ctest --test-dir %test_dir% --build-config Debug --output-on-failure --parallel 4
endlocal