0028920: Samples - fix msvc.bat for building samples without CMake
[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_GL2PS=false"
910970ab 23set "HAVE_VTK=false"
1ce0716b 24set "HAVE_GLES2=false"
f60111dc 25set "HAVE_D3D=false"
e22105a9 26set "HAVE_ZLIB=false"
27set "HAVE_LIBLZMA=false"
910970ab 28set "CSF_OPT_INC="
29set "CSF_OPT_LIB32="
30set "CSF_OPT_LIB64="
31set "CSF_OPT_BIN32="
32set "CSF_OPT_BIN64="
33
34rem ----- Load local settings -----
35if exist "%~dp0custom.bat" (
36 call "%~dp0custom.bat" %1 %2 %3 %4 %5
37)
38
e31a8e52 39if not ["%CASROOT%"] == [""] if exist "%SCRIPTROOT%\%CASROOT%" set "CASROOT=%SCRIPTROOT%\%CASROOT%"
40if ["%CASROOT%"] == [""] set "CASROOT=%SCRIPTROOT%"
41
910970ab 42rem ----- Read script arguments (override local settings) -----
43if not ["%1"] == [""] set "VCVER=%1"
44if not ["%2"] == [""] set "ARCH=%2"
45if /I ["%ARCH%"] == ["win32"] set "ARCH=32"
46if /I ["%ARCH%"] == ["win64"] set "ARCH=64"
47if /I ["%3"] == ["debug"] set "CASDEB=d"
48if /I ["%3"] == ["d"] set "CASDEB=d"
316d77d9 49if /I ["%3"] == ["i"] set "CASDEB=i"
50if /I ["%3"] == ["relwithdeb"] set "CASDEB=i"
910970ab 51
d6cda17a 52rem Decode VCVER
53call "%~dp0adm\vcver.bat"
54
48691eaa 55rem ----- Parsing of Visual Studio platform -----
56set "VisualStudioExpressName=VCExpress"
57
58if not "%DevEnvDir%" == "" (
59 rem If DevEnvDir is already defined (e.g. in custom.bat), use that value
60) else if /I "%VCFMT%" == "vc10" (
61 set "DevEnvDir=%VS100COMNTOOLS%..\IDE"
62) else if /I "%VCFMT%" == "vc11" (
63 set "DevEnvDir=%VS110COMNTOOLS%..\IDE"
64 rem Visual Studio Express starting from VS 2012 is called "for Windows Desktop"
65 rem and has a new name for executable - WDExpress
66 set "VisualStudioExpressName=WDExpress"
67) else if /I "%VCFMT%" == "vc12" (
68 set "DevEnvDir=%VS120COMNTOOLS%..\IDE"
69 set "VisualStudioExpressName=WDExpress"
70) else if /I "%VCFMT%" == "vc14" (
71 set "DevEnvDir=%VS140COMNTOOLS%..\IDE"
72) else if /I "%VCFMT%" == "vc141" (
73 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
74 set "DevEnvDir=%%i\Common7\IDE\"
75 )
76) else (
77 echo Error: wrong VS identifier
78 exit /B
79)
80
81rem ----- Parsing vcvarsall for qt samples and define PlatformToolset -----
82if /I "%VCFMT%" == "vc10" (
83 set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
84 set "VCPlatformToolSet=v100"
85) else if /I "%VCFMT%" == "vc11" (
86 set "VCVARS=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat"
87 set "VCPlatformToolSet=v110"
88) else if /I "%VCFMT%" == "vc12" (
89 set "VCVARS=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat"
90 set "VCPlatformToolSet=v120"
91) else if /I "%VCFMT%" == "vc14" (
92 set "VCVARS=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat"
93 set "VCPlatformToolSet=v140"
94) else if /I "%VCFMT%" == "vc141" (
95 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
96 set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
97 )
98 set "VCPlatformToolSet=v141"
99) else (
100 echo Error: first argument ^(%VCVER%^) should specify supported version of Visual C++,
101 echo one of: vc10 ^(VS 2010 SP3^), vc11 ^(VS 2012 SP3^), vc12 ^(VS 2013^) or vc14 ^(VS 2015^)
102 exit
103)
104
72c37458 105set "CSF_OPT_LIB32D=%CSF_OPT_LIB32%"
106set "CSF_OPT_LIB64D=%CSF_OPT_LIB64%"
107set "CSF_OPT_BIN32D=%CSF_OPT_BIN32%"
108set "CSF_OPT_BIN64D=%CSF_OPT_BIN64%"
109set "CSF_OPT_LIB32I=%CSF_OPT_LIB32%"
110set "CSF_OPT_LIB64I=%CSF_OPT_LIB64%"
111set "CSF_OPT_BIN32I=%CSF_OPT_BIN32%"
112set "CSF_OPT_BIN64I=%CSF_OPT_BIN64%"
910970ab 113
114rem ----- Optional 3rd-parties should be enabled by HAVE macros -----
115set "CSF_OPT_CMPL="
116set "PRODUCTS_DEFINES="
e22105a9 117if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" & set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%"
118if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" & set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%"
119if ["%HAVE_GL2PS%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GL2PS" & set "CSF_DEFINES=HAVE_GL2PS;%CSF_DEFINES%"
120if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%"
121if ["%HAVE_FFMPEG%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FFMPEG" & set "CSF_DEFINES=HAVE_FFMPEG;%CSF_DEFINES%"
122if ["%HAVE_VTK%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_VTK" & set "CSF_DEFINES=HAVE_VTK;%CSF_DEFINES%"
123if ["%HAVE_GLES2%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GLES2" & set "CSF_DEFINES=HAVE_GLES2;%CSF_DEFINES%"
124if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_D3D" & set "CSF_DEFINES=HAVE_D3D;%CSF_DEFINES%"
125if ["%HAVE_ZLIB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_ZLIB" & set "CSF_DEFINES=HAVE_ZLIB;%CSF_DEFINES%"
126if ["%HAVE_LIBLZMA%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_LIBLZMA" & set "CSF_DEFINES=HAVE_LIBLZMA;%CSF_DEFINES%"
910970ab 127
128rem Eliminate VS warning
129if ["%CSF_DEFINES%"] == [""] set "CSF_DEFINES=;"
130
131rem ----- Optional 3rd-parties should be enabled by HAVE macros -----
132if not ["%PRODUCTS_DEFINES%"] == [""] set "CSF_OPT_CMPL=%CSF_OPT_CMPL% %PRODUCTS_DEFINES%"
133
134rem ----- Colect 3rd-parties additional include paths into compiler options -----
135for %%a in ("%CSF_OPT_INC:;=";"%") do (
136 set "anItem=%%~a"
137 if not ["%%~a"] == [""] call :concatCmplInc %%~a
138)
139
140rem ----- Colect 3rd-parties additional library paths (32-bit) into linker options -----
141set "OPT_LIB32="
142for %%a in ("%CSF_OPT_LIB32:;=";"%") do (
143 set "anItem=%%~a"
144 if not ["%%~a"] == [""] call :concatLib32 %%~a
145)
146
147rem ----- Colect 3rd-parties additional library paths (64-bit) into linker options -----
148set "OPT_LIB64="
149for %%a in ("%CSF_OPT_LIB64:;=";"%") do (
150 set "anItem=%%~a"
151 if not ["%%~a"] == [""] call :concatLib64 %%~a
152)
153
910970ab 154set "CSF_OPT_LNK32=%CSF_OPT_LNK32% %OPT_LIB32%"
910970ab 155set "CSF_OPT_LNK64=%CSF_OPT_LNK64% %OPT_LIB64%"
316d77d9 156set "CSF_OPT_LNK32D=%CSF_OPT_LNK32D% %OPT_LIB32%"
910970ab 157set "CSF_OPT_LNK64D=%CSF_OPT_LNK64D% %OPT_LIB64%"
316d77d9 158set "CSF_OPT_LNK32I=%CSF_OPT_LNK32I% %OPT_LIB32%"
159set "CSF_OPT_LNK64I=%CSF_OPT_LNK64I% %OPT_LIB64%"
910970ab 160
4b3541c6 161rem ----- Default paths to sub-folders (can be different in install env) -----
162if "%CSF_OCCTIncludePath%" == "" set "CSF_OCCTIncludePath=%CASROOT%\inc"
163if "%CSF_OCCTResourcePath%" == "" set "CSF_OCCTResourcePath=%CASROOT%\src"
164if "%CSF_OCCTSamplesPath%" == "" set "CSF_OCCTSamplesPath=%CASROOT%\samples"
165if "%CSF_OCCTDataPath%" == "" set "CSF_OCCTDataPath=%CASROOT%\data"
166if "%CSF_OCCTTestsPath%" == "" set "CSF_OCCTTestsPath=%CASROOT%\tests"
d6cda17a 167if "%CSF_OCCTBinPath%" == "" set "CSF_OCCTBinPath=%CASROOT%\win%ARCH%\%VCLIB%\bin%CASDEB%"
168if "%CSF_OCCTLibPath%" == "" set "CSF_OCCTLibPath=%CASROOT%\win%ARCH%\%VCLIB%\lib%CASDEB%"
910970ab 169
170rem ----- Set path to 3rd party and OCCT libraries -----
4b3541c6 171set "PATH=%CSF_OCCTBinPath%;%PATH%"
316d77d9 172if ["%CASDEB%"] == [""] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32%;%PATH%"
173if ["%CASDEB%"] == [""] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64%;%PATH%"
174if ["%CASDEB%"] == ["d"] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32D%;%PATH%"
175if ["%CASDEB%"] == ["d"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64D%;%PATH%"
316d77d9 176if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32I%;%PATH%"
177if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64I%;%PATH%"
910970ab 178
179rem ----- Set envoronment variables used by OCCT -----
180set CSF_LANGUAGE=us
181set MMGT_CLEAR=1
4b3541c6 182set "CSF_SHMessage=%CSF_OCCTResourcePath%\SHMessage"
183set "CSF_MDTVTexturesDirectory=%CSF_OCCTResourcePath%\Textures"
184set "CSF_ShadersDirectory=%CSF_OCCTResourcePath%\Shaders"
185set "CSF_XSMessage=%CSF_OCCTResourcePath%\XSMessage"
186set "CSF_TObjMessage=%CSF_OCCTResourcePath%\TObj"
187set "CSF_StandardDefaults=%CSF_OCCTResourcePath%\StdResource"
188set "CSF_PluginDefaults=%CSF_OCCTResourcePath%\StdResource"
189set "CSF_XCAFDefaults=%CSF_OCCTResourcePath%\StdResource"
190set "CSF_TObjDefaults=%CSF_OCCTResourcePath%\StdResource"
191set "CSF_StandardLiteDefaults=%CSF_OCCTResourcePath%\StdResource"
4b3541c6 192set "CSF_IGESDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
193set "CSF_STEPDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
194set "CSF_XmlOcafResource=%CSF_OCCTResourcePath%\XmlOcafResource"
195set "CSF_MIGRATION_TYPES=%CSF_OCCTResourcePath%\StdResource\MigrationSheet.txt"
910970ab 196
197rem Draw Harness special stuff
4b3541c6 198if exist "%CSF_OCCTResourcePath%\DrawResources\DrawDefault" (
199 set "DRAWDEFAULT=%CSF_OCCTResourcePath%\DrawResources\DrawDefault"
200)
201if exist "%CSF_OCCTResourcePath%\DrawResources" (
202 set "DRAWHOME=%CSF_OCCTResourcePath%\DrawResources"
910970ab 203 set "CSF_DrawPluginDefaults=%DRAWHOME%"
204)
910970ab 205goto :eof
206
207:concatCmplInc
208set "CSF_OPT_CMPL=%CSF_OPT_CMPL% -I%1"
209goto :eof
210
211:concatLib32
7c65581d 212rem Compiler options for Code::Blocks: -L for gcc/mingw and /LIBPATH for msvc
213rem set "OPT_LIB32=%OPT_LIB32% /LIBPATH:%1"
214set "OPT_LIB32=%OPT_LIB32% -L%1"
910970ab 215goto :eof
216
217:concatLib64
7c65581d 218rem Compiler options for Code::Blocks: -L for gcc/mingw and /LIBPATH for msvc
219rem set "OPT_LIB64=%OPT_LIB64% /LIBPATH:%1"
220set "OPT_LIB64=%OPT_LIB64% -L%1"
910970ab 221goto :eof