Update of environment files
[occt.git] / adm / templates / env.bat
CommitLineData
910970ab 1@echo off
2
3rem Use:
4rem - first argument specifies version of Visual Studio (vc8, vc9, or vc10),
5rem - second argument specifies architecture (win32 or win64),
6rem - third argument specifies build mode (Debug or Release)
7rem Default options are:
8rem vc8 win32 Release
9
10set "SCRIPTROOT=%~dp0"
11set "SCRIPTROOT=%SCRIPTROOT:~0,-1%"
910970ab 12
13rem ----- Reset values to defaults -----
14set "CASDEB="
72c37458 15set "VCVER=vc10"
16set "ARCH=64"
910970ab 17set "VCVARS="
18set "HAVE_TBB=false"
19set "HAVE_OPENCL=false"
20set "HAVE_FREEIMAGE=false"
e22105a9 21set "HAVE_FFMPEG=false"
910970ab 22set "HAVE_VTK=false"
1ce0716b 23set "HAVE_GLES2=false"
f60111dc 24set "HAVE_D3D=false"
e22105a9 25set "HAVE_ZLIB=false"
26set "HAVE_LIBLZMA=false"
0a419c51 27set "HAVE_RAPIDJSON=false"
27bd52b5 28set "HAVE_E57=false"
910970ab 29set "CSF_OPT_INC="
30set "CSF_OPT_LIB32="
31set "CSF_OPT_LIB64="
32set "CSF_OPT_BIN32="
33set "CSF_OPT_BIN64="
d9166000 34set "CSF_DEFINES=%CSF_DEFINES_EXTRA%"
910970ab 35
e31a8e52 36if not ["%CASROOT%"] == [""] if exist "%SCRIPTROOT%\%CASROOT%" set "CASROOT=%SCRIPTROOT%\%CASROOT%"
37if ["%CASROOT%"] == [""] set "CASROOT=%SCRIPTROOT%"
38
249dd6ed 39rem ----- Load local settings -----
40if exist "%CASROOT%\custom.bat" (
41 call "%CASROOT%\custom.bat" %1 %2 %3 %4 %5
42)
43
910970ab 44rem ----- Read script arguments (override local settings) -----
45if not ["%1"] == [""] set "VCVER=%1"
46if not ["%2"] == [""] set "ARCH=%2"
47if /I ["%ARCH%"] == ["win32"] set "ARCH=32"
48if /I ["%ARCH%"] == ["win64"] set "ARCH=64"
49if /I ["%3"] == ["debug"] set "CASDEB=d"
50if /I ["%3"] == ["d"] set "CASDEB=d"
316d77d9 51if /I ["%3"] == ["i"] set "CASDEB=i"
52if /I ["%3"] == ["relwithdeb"] set "CASDEB=i"
910970ab 53
249dd6ed 54rem Decode VCVER variable and define related ones:
55rem
56rem VCFMT - "vc" followed by full version number of Visual Studio toolset
57rem (same as VCVER without optional suffix "-uwp")
58rem VCLIB - name of folder contining binaries
59rem (same as VCVER except without third version in number)
60rem VCPROP - name of required Visual Studion Workload (starting with VS 2017)
61rem
62rem Note that for VS before 2015 (vc14) always
63rem VCFMT=VCLIB=VCVER and VCPROP=NativeDesktop
64
65rem Since VS 2017, environment variables like VS100COMNTOOLS are not defined
66rem any more, we can only use vswhere.exe tool to find Visual Studio.
67rem Add path to vswhere.exe
68set "PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
69
70rem for vc10-12, interpretation is trivial
71set VCFMT=%VCVER%
72set VCLIB=%VCVER:~0,4%
73set VCPROP=NativeDesktop
74rem vc14 and later can have optional suffix "-uwp"
75if "%VCVER:~-4%" == "-uwp" (
76 set VCFMT=%VCVER:~0,-4%
77 set VCLIB=%VCLIB%-uwp
78 set VCPROP=Universal
79)
80rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP%
d6cda17a 81
48691eaa 82rem ----- Parsing of Visual Studio platform -----
83set "VisualStudioExpressName=VCExpress"
84
85if not "%DevEnvDir%" == "" (
86 rem If DevEnvDir is already defined (e.g. in custom.bat), use that value
71c810df 87) else if /I "%VCFMT%" == "vc9" (
88 set "DevEnvDir=%VS90COMNTOOLS%..\IDE"
48691eaa 89) else if /I "%VCFMT%" == "vc10" (
90 set "DevEnvDir=%VS100COMNTOOLS%..\IDE"
91) else if /I "%VCFMT%" == "vc11" (
92 set "DevEnvDir=%VS110COMNTOOLS%..\IDE"
93 rem Visual Studio Express starting from VS 2012 is called "for Windows Desktop"
94 rem and has a new name for executable - WDExpress
95 set "VisualStudioExpressName=WDExpress"
96) else if /I "%VCFMT%" == "vc12" (
97 set "DevEnvDir=%VS120COMNTOOLS%..\IDE"
98 set "VisualStudioExpressName=WDExpress"
99) else if /I "%VCFMT%" == "vc14" (
100 set "DevEnvDir=%VS140COMNTOOLS%..\IDE"
101) else if /I "%VCFMT%" == "vc141" (
102 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
103 set "DevEnvDir=%%i\Common7\IDE\"
104 )
d9619512 105) else if /I "%VCFMT%" == "vc142" (
106 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
107 set "DevEnvDir=%%i\Common7\IDE\"
108 )
c0f08310 109) else if /I "%VCFMT%" == "gcc" (
110 rem MinGW
48691eaa 111) else (
71c810df 112 echo Error: first argument ^(%VCVER%^) should specify supported version of Visual C++,
113 echo one of:
114 echo vc9 = VS 2008 ^(SP1^)
115 echo vc10 = VS 2010 ^(SP3^)
116 echo vc11 = VS 2012 ^(SP3^)
117 echo vc12 = VS 2013 ^(SP3^)
118 echo vc14 = VS 2015
119 echo vc141 = VS 2017
d9619512 120 echo vc142 = VS 2019
48691eaa 121 exit /B
122)
123
124rem ----- Parsing vcvarsall for qt samples and define PlatformToolset -----
71c810df 125if /I "%VCFMT%" == "vc9" (
126 set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat"
127 set "VCPlatformToolSet=v90"
128) else if /I "%VCFMT%" == "vc10" (
48691eaa 129 set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
130 set "VCPlatformToolSet=v100"
131) else if /I "%VCFMT%" == "vc11" (
132 set "VCVARS=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat"
133 set "VCPlatformToolSet=v110"
134) else if /I "%VCFMT%" == "vc12" (
135 set "VCVARS=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat"
136 set "VCPlatformToolSet=v120"
137) else if /I "%VCFMT%" == "vc14" (
138 set "VCVARS=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat"
139 set "VCPlatformToolSet=v140"
140) else if /I "%VCFMT%" == "vc141" (
141 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
142 set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
143 )
144 set "VCPlatformToolSet=v141"
d9619512 145) else if /I "%VCFMT%" == "vc142" (
146 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
147 set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
148 )
149 set "VCPlatformToolSet=v142"
c0f08310 150) else if /I "%VCFMT%" == "gcc" (
151 rem MinGW
48691eaa 152) else (
71c810df 153 echo Error: wrong VS identifier
154 exit /B
48691eaa 155)
156
72c37458 157set "CSF_OPT_LIB32D=%CSF_OPT_LIB32%"
158set "CSF_OPT_LIB64D=%CSF_OPT_LIB64%"
159set "CSF_OPT_BIN32D=%CSF_OPT_BIN32%"
160set "CSF_OPT_BIN64D=%CSF_OPT_BIN64%"
161set "CSF_OPT_LIB32I=%CSF_OPT_LIB32%"
162set "CSF_OPT_LIB64I=%CSF_OPT_LIB64%"
163set "CSF_OPT_BIN32I=%CSF_OPT_BIN32%"
164set "CSF_OPT_BIN64I=%CSF_OPT_BIN64%"
910970ab 165
166rem ----- Optional 3rd-parties should be enabled by HAVE macros -----
167set "CSF_OPT_CMPL="
168set "PRODUCTS_DEFINES="
e22105a9 169if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" & set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%"
170if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" & set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%"
e22105a9 171if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%"
172if ["%HAVE_FFMPEG%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FFMPEG" & set "CSF_DEFINES=HAVE_FFMPEG;%CSF_DEFINES%"
173if ["%HAVE_VTK%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_VTK" & set "CSF_DEFINES=HAVE_VTK;%CSF_DEFINES%"
174if ["%HAVE_GLES2%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GLES2" & set "CSF_DEFINES=HAVE_GLES2;%CSF_DEFINES%"
175if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_D3D" & set "CSF_DEFINES=HAVE_D3D;%CSF_DEFINES%"
176if ["%HAVE_ZLIB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_ZLIB" & set "CSF_DEFINES=HAVE_ZLIB;%CSF_DEFINES%"
177if ["%HAVE_LIBLZMA%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_LIBLZMA" & set "CSF_DEFINES=HAVE_LIBLZMA;%CSF_DEFINES%"
0a419c51 178if ["%HAVE_RAPIDJSON%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_RAPIDJSON" & set "CSF_DEFINES=HAVE_RAPIDJSON;%CSF_DEFINES%"
27bd52b5 179if ["%HAVE_E57%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_E57" & set "CSF_DEFINES=HAVE_E57;%CSF_DEFINES%"
910970ab 180
181rem Eliminate VS warning
182if ["%CSF_DEFINES%"] == [""] set "CSF_DEFINES=;"
183
184rem ----- Optional 3rd-parties should be enabled by HAVE macros -----
185if not ["%PRODUCTS_DEFINES%"] == [""] set "CSF_OPT_CMPL=%CSF_OPT_CMPL% %PRODUCTS_DEFINES%"
186
187rem ----- Colect 3rd-parties additional include paths into compiler options -----
188for %%a in ("%CSF_OPT_INC:;=";"%") do (
189 set "anItem=%%~a"
190 if not ["%%~a"] == [""] call :concatCmplInc %%~a
191)
192
193rem ----- Colect 3rd-parties additional library paths (32-bit) into linker options -----
194set "OPT_LIB32="
195for %%a in ("%CSF_OPT_LIB32:;=";"%") do (
196 set "anItem=%%~a"
197 if not ["%%~a"] == [""] call :concatLib32 %%~a
198)
199
200rem ----- Colect 3rd-parties additional library paths (64-bit) into linker options -----
201set "OPT_LIB64="
202for %%a in ("%CSF_OPT_LIB64:;=";"%") do (
203 set "anItem=%%~a"
204 if not ["%%~a"] == [""] call :concatLib64 %%~a
205)
206
910970ab 207set "CSF_OPT_LNK32=%CSF_OPT_LNK32% %OPT_LIB32%"
910970ab 208set "CSF_OPT_LNK64=%CSF_OPT_LNK64% %OPT_LIB64%"
316d77d9 209set "CSF_OPT_LNK32D=%CSF_OPT_LNK32D% %OPT_LIB32%"
910970ab 210set "CSF_OPT_LNK64D=%CSF_OPT_LNK64D% %OPT_LIB64%"
316d77d9 211set "CSF_OPT_LNK32I=%CSF_OPT_LNK32I% %OPT_LIB32%"
212set "CSF_OPT_LNK64I=%CSF_OPT_LNK64I% %OPT_LIB64%"
910970ab 213
4b3541c6 214rem ----- Default paths to sub-folders (can be different in install env) -----
215if "%CSF_OCCTIncludePath%" == "" set "CSF_OCCTIncludePath=%CASROOT%\inc"
216if "%CSF_OCCTResourcePath%" == "" set "CSF_OCCTResourcePath=%CASROOT%\src"
217if "%CSF_OCCTSamplesPath%" == "" set "CSF_OCCTSamplesPath=%CASROOT%\samples"
218if "%CSF_OCCTDataPath%" == "" set "CSF_OCCTDataPath=%CASROOT%\data"
219if "%CSF_OCCTTestsPath%" == "" set "CSF_OCCTTestsPath=%CASROOT%\tests"
d6cda17a 220if "%CSF_OCCTBinPath%" == "" set "CSF_OCCTBinPath=%CASROOT%\win%ARCH%\%VCLIB%\bin%CASDEB%"
221if "%CSF_OCCTLibPath%" == "" set "CSF_OCCTLibPath=%CASROOT%\win%ARCH%\%VCLIB%\lib%CASDEB%"
910970ab 222
223rem ----- Set path to 3rd party and OCCT libraries -----
4b3541c6 224set "PATH=%CSF_OCCTBinPath%;%PATH%"
316d77d9 225if ["%CASDEB%"] == [""] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32%;%PATH%"
226if ["%CASDEB%"] == [""] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64%;%PATH%"
227if ["%CASDEB%"] == ["d"] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32D%;%PATH%"
228if ["%CASDEB%"] == ["d"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64D%;%PATH%"
316d77d9 229if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32I%;%PATH%"
230if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64I%;%PATH%"
910970ab 231
232rem ----- Set envoronment variables used by OCCT -----
233set CSF_LANGUAGE=us
234set MMGT_CLEAR=1
4b3541c6 235set "CSF_SHMessage=%CSF_OCCTResourcePath%\SHMessage"
236set "CSF_MDTVTexturesDirectory=%CSF_OCCTResourcePath%\Textures"
237set "CSF_ShadersDirectory=%CSF_OCCTResourcePath%\Shaders"
238set "CSF_XSMessage=%CSF_OCCTResourcePath%\XSMessage"
239set "CSF_TObjMessage=%CSF_OCCTResourcePath%\TObj"
240set "CSF_StandardDefaults=%CSF_OCCTResourcePath%\StdResource"
241set "CSF_PluginDefaults=%CSF_OCCTResourcePath%\StdResource"
242set "CSF_XCAFDefaults=%CSF_OCCTResourcePath%\StdResource"
243set "CSF_TObjDefaults=%CSF_OCCTResourcePath%\StdResource"
244set "CSF_StandardLiteDefaults=%CSF_OCCTResourcePath%\StdResource"
4b3541c6 245set "CSF_IGESDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
246set "CSF_STEPDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
247set "CSF_XmlOcafResource=%CSF_OCCTResourcePath%\XmlOcafResource"
248set "CSF_MIGRATION_TYPES=%CSF_OCCTResourcePath%\StdResource\MigrationSheet.txt"
910970ab 249
250rem Draw Harness special stuff
4b3541c6 251if exist "%CSF_OCCTResourcePath%\DrawResources\DrawDefault" (
252 set "DRAWDEFAULT=%CSF_OCCTResourcePath%\DrawResources\DrawDefault"
253)
254if exist "%CSF_OCCTResourcePath%\DrawResources" (
255 set "DRAWHOME=%CSF_OCCTResourcePath%\DrawResources"
910970ab 256 set "CSF_DrawPluginDefaults=%DRAWHOME%"
257)
910970ab 258goto :eof
259
260:concatCmplInc
261set "CSF_OPT_CMPL=%CSF_OPT_CMPL% -I%1"
262goto :eof
263
264:concatLib32
7c65581d 265rem Compiler options for Code::Blocks: -L for gcc/mingw and /LIBPATH for msvc
266rem set "OPT_LIB32=%OPT_LIB32% /LIBPATH:%1"
267set "OPT_LIB32=%OPT_LIB32% -L%1"
910970ab 268goto :eof
269
270:concatLib64
7c65581d 271rem Compiler options for Code::Blocks: -L for gcc/mingw and /LIBPATH for msvc
272rem set "OPT_LIB64=%OPT_LIB64% /LIBPATH:%1"
273set "OPT_LIB64=%OPT_LIB64% -L%1"
910970ab 274goto :eof