-
Notifications
You must be signed in to change notification settings - Fork 16
/
gen_vs_sln.bat
executable file
·145 lines (117 loc) · 2.98 KB
/
gen_vs_sln.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@echo off
rem *****************************************
rem Generates a fresh VS solution using CMake
rem *****************************************
echo.
rem Clean env
set CMAKE_BIN=
set _VSVER=
set _TARCH=
set _YEAR=
rem Try to locate cmake
where cmake 1>NUL 2>NUL
if %ERRORLEVEL% equ 0 (
for /f "tokens=*" %%i in ('where cmake') do set CMAKE_BIN=%%i
) else (
set CMAKE_BIN=C:\Program Files\CMake\bin\cmake.exe
)
if not defined CMAKE_BIN goto :cmerr
echo Using CMake: %CMAKE_BIN%
rem Visual Studio version as set by vcvarsXXX
set _VSVER=%VisualStudioVersion%
if not defined _VSVER goto :vserr
rem Try to pick an appropriate target arch
if "%1"=="/32" set _TARCH=x86
if not defined _TARCH set _TARCH=%VSCMD_ARG_TGT_ARCH%
if not defined _TARCH set _TARCH=x64
echo Using Visual Studio: %_VSVER%, target architecture: %_TARCH%
if not defined VSCMD_ARG_TGT_ARCH (
if %_TARCH%==x64 (
echo.
echo ====
echo WARN: Desired architecture cannot be detected on VS2015 and below.
echo Defaulting to 64-bit. Please re-run this script with the /32 flag
echo if you need to build for 32-bit.
echo ====
echo.
pause
)
)
rem Make or clean target directory
mkdir VS\%_TARCH% 2>NUL
cd VS\%_TARCH%
del /f/q/s *.* >NUL
echo.
rem CMakeLists.txt must point to Qt
echo.
echo ====
echo STOP: Did you remember to edit CMakeLists.txt to point to your Qt installation?
echo Do not continue until Qt_DIR is set correctly.
echo ====
echo.
pause
rem Run CMake with the appropriate VS generator
if "%_VSVER%"=="14.0" goto :vs14
if "%_VSVER%"=="15.0" goto :vs15
if "%_VSVER%"=="16.0" goto :vs16
:vs14
set _YEAR=2015
if "%_TARCH%"=="x64" set _ARCH= Win64
"%CMAKE_BIN%" -G"Visual Studio 14 2015%_ARCH%" ..\..
if %ERRORLEVEL% neq 0 goto :generr
goto :success
:vs15
set _YEAR=2017
if "%_TARCH%"=="x64" set _ARCH= Win64
"%CMAKE_BIN%" -G"Visual Studio 15 2017%_ARCH%" ..\..
if %ERRORLEVEL% neq 0 goto :generr
goto :success
:vs16
set _YEAR=2019
if "%_TARCH%"=="x64" set _ARCH= x64
"%CMAKE_BIN%" -G"Visual Studio 16 2019" -A%_ARCH% ..\..
if %ERRORLEVEL% neq 0 goto :generr
goto :success
:success
echo.
echo ====
echo SUCCESS: You can find the generated Visual Studio %_YEAR% solution at
echo %CD%\mwc-qt-wallet.sln
echo ====
cd ..\..
goto :end
:cmerr
echo.
echo ====
echo FATAL: Could not locate CMake. Please add it to your path or edit the CMAKE_BIN
echo variable at the beginning of this script.
echo ====
goto :end
:vserr
echo.
echo ====
echo FATAL: Could not detect Visual Studio version. Please run this script from
echo a Visual Studio developer command prompt or call vcvarsall.bat manually.
echo ====
goto :fail
:generr
echo.
echo ===
echo FATAL: CMake could not generate the Visual Studio %_YEAR% solution. Please check
echo the output above and ensure you have installed all the prerequisites outlined in
for %%a in ("%CD%\..\..") DO echo %%~dpaDOCS\BUILD_WINDOWS.md
echo ===
goto :fail
:fail
rem del /f/q/s *.* >NUL
cd ..
rem rmdir /Q/S %_TARCH%
cd ..
:end
rem Clean env
set CMAKE_BIN=
set _VSVER=
set _TARCH=
set _YEAR=
echo.
pause