update windows build to detect when a cross-compiler is necessary
authoralfadur
Thu, 22 Aug 2019 22:46:19 +0300
changeset 15354 96254b857257
parent 15353 e390ef1c7a5c
child 15355 81037b6052f4
update windows build to detect when a cross-compiler is necessary
hedgewars/CMakeLists.txt
tools/build_vcpkg.bat
--- a/hedgewars/CMakeLists.txt	Thu Aug 22 19:07:25 2019 +0300
+++ b/hedgewars/CMakeLists.txt	Thu Aug 22 22:46:19 2019 +0300
@@ -194,6 +194,9 @@
     add_flag_append(CMAKE_Pascal_FLAGS_DEBUG "-dVCPKG_DEBUG")
 endif()
 
+if (WIN32_WIN64_CROSS_COMPILE)
+    add_flag_append(CMAKE_Pascal_FLAGS "-Px86_64 -Twin64")
+endif()
 
 #SOURCE AND PROGRAMS SECTION
 if(BUILD_ENGINE_LIBRARY)
--- a/tools/build_vcpkg.bat	Thu Aug 22 19:07:25 2019 +0300
+++ b/tools/build_vcpkg.bat	Thu Aug 22 22:46:19 2019 +0300
@@ -1,5 +1,9 @@
 @echo off
+setlocal
+::CONFIG START
 ::edit these variables if necessary
+
+::change between "Debug" and "Release"
 set BUILD_TYPE="Release"
 ::set if vcpkg is not on path
 set VCPKG_PATH=%VCPKG_ROOT%
@@ -7,17 +11,35 @@
 set CMAKE_PATH=
 ::set if FPC is not on path
 set PASCAL_PATH=
+::set to 1 if x86 to x64 cross-compiler is not enabled automatically
+set FORCE_X64_CROSS_COMPILE=
+::set to 1 to build the game server
+set BUILD_SERVER=
 
+::CONFIG END
+            
 :setup
 set CURRDIR="%CD%"
 cd %CURRDIR%\..\
 
 set PATH=%PASCAL_PATH%;%VCPKG_PATH%;%CMAKE_PATH%;%PATH%
 
+if "%VSCMD_ARG_TGT_ARCH%" == "x64" (
+    set FORCE_X64_CROSS_COMPILE=1
+)
+
+if "%FORCE_X64_CROSS_COMPILE%" NEQ "" (
+    set CROSS_COMPILE_FLAG="-DWIN32_WIN64_CROSS_COMPILE=1"
+)
+
+if "%BUILD_SERVER%" == "" (
+    set BUILD_SERVER_FLAG="-DNOSERVER=1"
+)              
+
 echo Running cmake...
 set ERRORLEVEL=
 
-cmake . -DCMAKE_TOOLCHAIN_FILE="%VCPKG_PATH%\scripts\buildsystems\vcpkg.cmake" -G"NMake Makefiles" -DNOSERVER=1 -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DSDL2_BUILDING_LIBRARY=1
+cmake . -DCMAKE_TOOLCHAIN_FILE="%VCPKG_PATH%\scripts\buildsystems\vcpkg.cmake" -G"NMake Makefiles" "%CROSS_COMPILE_FLAG%" "%BUILD_SERVER_FLAG%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DSDL2_BUILDING_LIBRARY=1
 
 if %ERRORLEVEL% NEQ 0 goto exitpoint
 
@@ -36,4 +58,6 @@
 
 :exitpoint
 cd %CURRDIR%
+
+endlocal
 pause