This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/
gen-buildsys-win.bat
67 lines (54 loc) · 2.23 KB
/
gen-buildsys-win.bat
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
67
@if "%_echo%" neq "on" echo off
rem
rem This file invokes cmake and generates the build system for windows.
set argC=0
for %%x in (%*) do Set /A argC+=1
if NOT %argC%==3 GOTO :USAGE
if %1=="/?" GOTO :USAGE
setlocal
set __sourceDir=%~dp0
set __ExtraCmakeParams=
if "%__VSVersion%" == "vs2019" (
:: CMAKE 3.14 or later is required to use VS2019
set __VSString=16 2019
) else (
:: VS 2017 is the minimum supported toolset
set __VSString=15 2017
)
if /i "%3" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%3" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
if /i "%3" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%3" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%3" == "wasm" (set __sourceDir=%~dp0..\Unix && goto DoGen)
:: cmake requires forward slashes in paths
set __cmakeRepoRoot=%__repoRoot:\=/%
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%"
if defined CMakePath goto DoGen
:: Eval the output from probe-win1.ps1
pushd "%__sourceDir%"
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\probe-win.ps1"') do %%a
popd
:DoGen
if "%3" == "wasm" (
if "%EMSDK_PATH%" == "" (
echo "Error: Should set EMSDK_PATH environment variable pointing to emsdk root."
exit /B 1
)
if "%EMSCRIPTEN_ROOT%" == "" (
set EMSCRIPTEN_ROOT="%EMSDK_PATH/upstream/emscripten%"
)
emcmake cmake "-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1" "-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%" "-DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/Emscripten.cmake" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" -G "NMake Makefiles" %__sourceDir%
) else (
"%CMakePath%" %__SDKVersion% "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" -G "Visual Studio %__VSString%" -B. -H%1 %__ExtraCmakeParams%
)
endlocal
GOTO :DONE
:USAGE
echo "Usage..."
echo "gen-buildsys-win.bat <path to top level CMakeLists.txt> <VSVersion> <Target Architecture>"
echo "Specify the path to the top level CMake file"
echo "Specify the VSVersion to be used - VS2017"
echo "Specify the Target Architecture - AnyCPU, x86, x64, ARM, or ARM64."
EXIT /B 1
:DONE
EXIT /B 0