tools/build_vcpkg.bat
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15859 7b1d6dfa3173
parent 15350 81037b6052f4
child 15948 4ec24af5909a
permissions -rw-r--r--
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
     1
@echo off
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
     2
setlocal
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
     3
::CONFIG START
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
     4
::edit these variables if necessary
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
     5
15350
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
     6
::change between Debug and Release
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
     7
set BUILD_TYPE=Release
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
     8
::path where Hedgewars will be installed to
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
     9
::default is %ProgramFiles%\hedgewars and requires running this script as administrator  
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    10
set INSTALL_LOCATION=
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    11
::set if vcpkg is not on path
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    12
set VCPKG_PATH=%VCPKG_ROOT%
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    13
::set if CMake is not on path
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    14
set CMAKE_PATH=
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    15
::set if FPC is not on path
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    16
set PASCAL_PATH=
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    17
::set to 1 if x86 to x64 cross-compiler is not enabled automatically
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    18
set FORCE_X64_CROSS_COMPILE=
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    19
::set to 1 to build the game server
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    20
set BUILD_SERVER=
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    21
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    22
::CONFIG END
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    23
            
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    24
:setup
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    25
set CURRDIR="%CD%"
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    26
cd %CURRDIR%\..\
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    27
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    28
set PATH=%PASCAL_PATH%;%VCPKG_PATH%;%CMAKE_PATH%;%PATH%
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    29
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    30
if "%VSCMD_ARG_TGT_ARCH%" == "x64" (
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    31
    set FORCE_X64_CROSS_COMPILE=1
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    32
)
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    33
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    34
if "%FORCE_X64_CROSS_COMPILE%" NEQ "" (
15350
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    35
    set CROSS_COMPILE_FLAG=-DWIN32_WIN64_CROSS_COMPILE=1
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    36
    if "%INSTALL_LOCATION%" == "" (
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    37
        set INSTALL_LOCATION=%ProgramFiles%/hedgewars
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    38
    )
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    39
) else (
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    40
    set CROSS_COMPILE_FLAG=
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    41
)
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    42
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    43
if "%INSTALL_LOCATION%" NEQ "" (
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    44
    set PREFIX_FLAG=-DCMAKE_INSTALL_PREFIX=%INSTALL_LOCATION%
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    45
) else (
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    46
    set PREFIX_FLAG=
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    47
)
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    48
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    49
if "%BUILD_SERVER%" == "" (
15350
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    50
    set BUILD_SERVER_FLAG=-DNOSERVER=1
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    51
) else (
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    52
    set BUILD_SERVER_FLAG=
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    53
)             
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    54
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    55
echo Running cmake...
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    56
set ERRORLEVEL=
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    57
15350
81037b6052f4 install win64 builds into ProgramFiles by default
alfadur
parents: 15349
diff changeset
    58
cmake . -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
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    59
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    60
if %ERRORLEVEL% NEQ 0 goto exitpoint
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    61
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    62
echo Configuration completed successfully
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    63
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    64
echo Building...
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    65
set ERRORLEVEL=
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    66
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    67
nmake
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    68
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    69
if %ERRORLEVEL% NEQ 0 goto exitpoint
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    70
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    71
echo Build completed successfully
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    72
15315
90f9a0eac3ae remove nopng from vcpkg build
alfadur
parents: 14268
diff changeset
    73
nmake install
90f9a0eac3ae remove nopng from vcpkg build
alfadur
parents: 14268
diff changeset
    74
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    75
:exitpoint
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    76
cd %CURRDIR%
15349
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    77
96254b857257 update windows build to detect when a cross-compiler is necessary
alfadur
parents: 15347
diff changeset
    78
endlocal
13923
4d63acb2b978 Add basic windows build script
alfadur
parents:
diff changeset
    79
pause