1@echo off
2setlocal
3::CONFIG START
4::edit these variables if necessary
5
6::change between Debug and Release
7set BUILD_TYPE=Release
8::path where Hedgewars will be installed to
9::default is %ProgramFiles%\hedgewars and requires running this script as administrator
10set INSTALL_LOCATION=
11::set if vcpkg is not on path
12set VCPKG_PATH=%VCPKG_ROOT%
13::set if CMake is not on path
14set CMAKE_PATH=
15::set if FPC is not on path
16set PASCAL_PATH=
17::set to 1 if x86 to x64 cross-compiler is not enabled automatically
18set FORCE_X64_CROSS_COMPILE=
19::set to 1 to build the game server
20set BUILD_SERVER=
21
22::CONFIG END
23
24:setup
25set CURRDIR="%CD%"
26cd %CURRDIR%\..\
27
28set PATH=%PASCAL_PATH%;%VCPKG_PATH%;%CMAKE_PATH%;%PATH%
29
30if "%VSCMD_ARG_TGT_ARCH%" == "x64" (
31    set FORCE_X64_CROSS_COMPILE=1
32)
33
34if "%FORCE_X64_CROSS_COMPILE%" NEQ "" (
35    set CROSS_COMPILE_FLAG=-DWIN32_WIN64_CROSS_COMPILE=1
36    if "%INSTALL_LOCATION%" == "" (
37        set INSTALL_LOCATION=%ProgramFiles%/hedgewars
38    )
39) else (
40    set CROSS_COMPILE_FLAG=
41)
42
43if "%INSTALL_LOCATION%" NEQ "" (
44    set PREFIX_FLAG=-DCMAKE_INSTALL_PREFIX=%INSTALL_LOCATION%
45) else (
46    set PREFIX_FLAG=
47)
48
49if "%BUILD_SERVER%" == "" (
50    set BUILD_SERVER_FLAG=-DNOSERVER=1
51) else (
52    set BUILD_SERVER_FLAG=
53)
54
55echo Running cmake...
56set ERRORLEVEL=
57
58cmake . -DCMAKE_TOOLCHAIN_FILE="%VCPKG_PATH%\scripts\buildsystems\vcpkg.cmake" -G"NMake Makefiles" %CROSS_COMPILE_FLAG% %BUILD_SERVER_FLAG% "%PREFIX_FLAG%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DSDL2_BUILDING_LIBRARY=1
59
60if %ERRORLEVEL% NEQ 0 goto exitpoint
61
62echo Configuration completed successfully
63
64echo Building...
65set ERRORLEVEL=
66
67nmake
68
69if %ERRORLEVEL% NEQ 0 goto exitpoint
70
71echo Build completed successfully
72
73nmake install
74
75:exitpoint
76cd %CURRDIR%
77
78endlocal
79pause
80